Thu, 14 Aug 2014 19:14:04 +0200
Change root path to (more) approximate typical launch environment.
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 | Test: dig @nodeapp.host.tld A realhost.local |
41 | |
42 ***********************************************************/
44 // import module dependencies
45 var forkserv = require('forever-monitor');
48 // configure a child process to daemonize
49 var childproc = new (forkserv.Monitor)('src/lib/app.js', {
50 max: 4,
51 silent: true,
52 pidFile: '/tmp/mdnsgw.pid',
53 logFile: '/tmp/mdnsgw.log',
54 outFile: '/tmp/mdnsgw.out',
55 errFile: '/tmp/mdnsgw.err',
56 options: []
57 });
59 childproc.on('exit', function () {
60 console.log('app.js has exited after 4 restarts');
61 });
63 // fork a child
64 childproc.start();
66 //// daemonize by exit
67 //that doesn't work
68 //process.exit(0);