src/fork.js

changeset 0
eb6d4ce6fd78
child 4
3de96d11e417
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/fork.js	Tue Aug 12 18:32:40 2014 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +#! /usr/bin/env nodejs
     1.5 +//
     1.6 +//  mDNSGw - Zero Configuration DNS Gateway for Mesh Networks
     1.7 +//  Copyright © 2014 Michael Schloh von Bennewitz <michael@schloh.com>
     1.8 +//
     1.9 +//  Permission to use, copy, modify, and/or distribute this software for
    1.10 +//  any purpose with or without fee is hereby granted, provided that the
    1.11 +//  above copyright notice and this permission notice appear in all copies.
    1.12 +//
    1.13 +//  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
    1.14 +//  WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
    1.15 +//  WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
    1.16 +//  AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
    1.17 +//  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
    1.18 +//  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
    1.19 +//  ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
    1.20 +//  THIS SOFTWARE.
    1.21 +//
    1.22 +//  This file is part of mDNSGw, a Zero configuration DNS gateway
    1.23 +//  which can be found at http://dev.europalab.com/mdnsgw/
    1.24 +//
    1.25 +//  fork.js: ECMA JavaScript implementation
    1.26 +//
    1.27 +
    1.28 +/***********************************************************
    1.29 +|                  ____  _   _ ____   ____                 |
    1.30 +|        _ __ ___ |  _ \| \ | / ___| / ___|_      __       |
    1.31 +|       | '_ ` _ \| | | |  \| \___ \| |  _\ \ /\ / /       |
    1.32 +|       | | | | | | |_| | |\  |___) | |_| |\ V  V /        |
    1.33 +|       |_| |_| |_|____/|_| \_|____/ \____| \_/\_/         |
    1.34 +|                                                          |
    1.35 +| Requirements: Redis server with standard configuration   |
    1.36 +|               NodeJS and NPM modules (see package.json)  |
    1.37 +|                                                          |
    1.38 +| Execute: To start this application, launch it with the   |
    1.39 +|          script named fork.js: $ ./fork.js               |
    1.40 +|                                                          |
    1.41 +| Support: http://list.europalab.com/mailman/mdnsgs/       |
    1.42 +|                                                          |
    1.43 +***********************************************************/
    1.44 +
    1.45 +// import module dependencies
    1.46 +var forkserv = require('forever-monitor');
    1.47 +
    1.48 +
    1.49 +// configure a child process to daemonize
    1.50 +var childproc = new (forkserv.Monitor)('app.js', {
    1.51 +  max: 4,
    1.52 +  silent: true,
    1.53 +  pidFile: 'mdnsgw.pid',
    1.54 +  logFile: 'mdnsgw.log',
    1.55 +  outFile: 'mdnsgw.out',
    1.56 +  errFile: 'mdnsgw.err',
    1.57 +  options: []
    1.58 +});
    1.59 +
    1.60 +childproc.on('exit', function () {
    1.61 +  console.log('app.js has exited after 4 restarts');
    1.62 +});
    1.63 +
    1.64 +// fork a child
    1.65 +childproc.start();

mercurial