src/fork.js

changeset 0
eb6d4ce6fd78
child 4
3de96d11e417
equal deleted inserted replaced
-1:000000000000 0:2386daed63d0
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 //
24
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 ***********************************************************/
41
42 // import module dependencies
43 var forkserv = require('forever-monitor');
44
45
46 // configure a child process to daemonize
47 var childproc = new (forkserv.Monitor)('app.js', {
48 max: 4,
49 silent: true,
50 pidFile: 'mdnsgw.pid',
51 logFile: 'mdnsgw.log',
52 outFile: 'mdnsgw.out',
53 errFile: 'mdnsgw.err',
54 options: []
55 });
56
57 childproc.on('exit', function () {
58 console.log('app.js has exited after 4 restarts');
59 });
60
61 // fork a child
62 childproc.start();

mercurial