michael@0: #! /usr/bin/env nodejs michael@0: // michael@0: // mDNSGw - Zero Configuration DNS Gateway for Mesh Networks michael@0: // Copyright © 2014 Michael Schloh von Bennewitz michael@0: // michael@0: // Permission to use, copy, modify, and/or distribute this software for michael@0: // any purpose with or without fee is hereby granted, provided that the michael@0: // above copyright notice and this permission notice appear in all copies. michael@0: // michael@0: // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL michael@0: // WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED michael@0: // WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE michael@0: // AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL michael@0: // DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR michael@0: // PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS michael@0: // ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF michael@0: // THIS SOFTWARE. michael@0: // michael@0: // This file is part of mDNSGw, a Zero configuration DNS gateway michael@0: // which can be found at http://dev.europalab.com/mdnsgw/ michael@0: // michael@0: // fork.js: ECMA JavaScript implementation michael@0: // michael@0: michael@0: /*********************************************************** michael@0: | ____ _ _ ____ ____ | michael@0: | _ __ ___ | _ \| \ | / ___| / ___|_ __ | michael@0: | | '_ ` _ \| | | | \| \___ \| | _\ \ /\ / / | michael@0: | | | | | | | |_| | |\ |___) | |_| |\ V V / | michael@0: | |_| |_| |_|____/|_| \_|____/ \____| \_/\_/ | michael@0: | | michael@0: | Requirements: Redis server with standard configuration | michael@0: | NodeJS and NPM modules (see package.json) | michael@0: | | michael@0: | Execute: To start this application, launch it with the | michael@0: | script named fork.js: $ ./fork.js | michael@0: | | michael@0: | Support: http://list.europalab.com/mailman/mdnsgs/ | michael@0: | | michael@0: ***********************************************************/ michael@0: michael@0: // import module dependencies michael@0: var forkserv = require('forever-monitor'); michael@0: michael@0: michael@0: // configure a child process to daemonize michael@0: var childproc = new (forkserv.Monitor)('app.js', { michael@0: max: 4, michael@0: silent: true, michael@4: pidFile: '/tmp/mdnsgw.pid', michael@4: logFile: '/tmp/mdnsgw.log', michael@4: outFile: '/tmp/mdnsgw.out', michael@4: errFile: '/tmp/mdnsgw.err', michael@0: options: [] michael@0: }); michael@0: michael@0: childproc.on('exit', function () { michael@0: console.log('app.js has exited after 4 restarts'); michael@0: }); michael@0: michael@0: // fork a child michael@0: childproc.start(); michael@4: michael@4: //// daemonize by exit michael@4: //that doesn't work michael@4: //process.exit(0);