src/fork.js

Wed, 13 Aug 2014 21:01:00 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 13 Aug 2014 21:01:00 +0200
changeset 4
3de96d11e417
parent 0
eb6d4ce6fd78
permissions
-rwxr-xr-x

Write logs and output to temp until a configuration variable exists.

     1 #! /usr/bin/env nodejs
     2 //
     3 //  mDNSGw - Zero Configuration DNS Gateway for Mesh Networks
     4 //  Copyright © 2014 Michael Schloh von Bennewitz <michael@schloh.com>
     5 //
     6 //  Permission to use, copy, modify, and/or distribute this software for
     7 //  any purpose with or without fee is hereby granted, provided that the
     8 //  above copyright notice and this permission notice appear in all copies.
     9 //
    10 //  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
    11 //  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
    12 //  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
    13 //  AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
    14 //  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
    15 //  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
    16 //  ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
    17 //  THIS SOFTWARE.
    18 //
    19 //  This file is part of mDNSGw, a Zero configuration DNS gateway
    20 //  which can be found at http://dev.europalab.com/mdnsgw/
    21 //
    22 //  fork.js: ECMA JavaScript implementation
    23 //
    25 /***********************************************************
    26 |                  ____  _   _ ____   ____                 |
    27 |        _ __ ___ |  _ \| \ | / ___| / ___|_      __       |
    28 |       | '_ ` _ \| | | |  \| \___ \| |  _\ \ /\ / /       |
    29 |       | | | | | | |_| | |\  |___) | |_| |\ V  V /        |
    30 |       |_| |_| |_|____/|_| \_|____/ \____| \_/\_/         |
    31 |                                                          |
    32 | Requirements: Redis server with standard configuration   |
    33 |               NodeJS and NPM modules (see package.json)  |
    34 |                                                          |
    35 | Execute: To start this application, launch it with the   |
    36 |          script named fork.js: $ ./fork.js               |
    37 |                                                          |
    38 | Support: http://list.europalab.com/mailman/mdnsgs/       |
    39 |                                                          |
    40 ***********************************************************/
    42 // import module dependencies
    43 var forkserv = require('forever-monitor');
    46 // configure a child process to daemonize
    47 var childproc = new (forkserv.Monitor)('app.js', {
    48   max: 4,
    49   silent: true,
    50   pidFile: '/tmp/mdnsgw.pid',
    51   logFile: '/tmp/mdnsgw.log',
    52   outFile: '/tmp/mdnsgw.out',
    53   errFile: '/tmp/mdnsgw.err',
    54   options: []
    55 });
    57 childproc.on('exit', function () {
    58   console.log('app.js has exited after 4 restarts');
    59 });
    61 // fork a child
    62 childproc.start();
    64 //// daemonize by exit
    65 //that doesn't work
    66 //process.exit(0);

mercurial