PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` var fs = require('fs'), path = require('path'), forever = require(path.resolve(__dirname, '..', 'lib', 'forever')), started; // // ### @function (file, pid) // #### @file {string} Location of the pid file. // #### @pid {number} pid to write to disk. // Write the pidFile to disk for later use // function writePid(file, pid) { fs.writeFileSync(file, String(pid), 'utf8'); } // // ### @function start (options) // #### @options {Object} Options for the `forever.Monitor` instance. // Starts the child process and disconnects from the IPC channel. // function start(options) { var script = process.argv[2], monitor = new forever.Monitor(script, options); forever.logEvents(monitor); monitor.start(); monitor.on('start', function () { // // This starts an nssocket server, which the forever CLI uses to // communicate with this monitor process after it's detached. // Without this, `forever list` won't show the process, even though it // would still be running in the background unaffected. // forever.startServer(monitor); // // Disconnect the IPC channel, letting this monitor's parent process know // that the child has started successfully. // process.disconnect(); // // Write the pidFile to disk // writePid(options.pidFile, monitor.child.pid); }); // // When the monitor restarts update the pid in the pidFile // monitor.on('restart', function () { writePid(options.pidFile, monitor.child.pid); }); // // When the monitor stops or exits, remove the pid and log files // function cleanUp() { try { fs.unlinkSync(options.pidFile); } catch(e) {} } monitor.on('stop', cleanUp); monitor.on('exit', cleanUp); } // // When we receive the first message from the parent process, start // an instance of `forever.Monitor` with the options supplied. // process.on('message', function (data) { // // TODO: Find out if this data will ever get split into two message events. // var options = JSON.parse(data.toString()); // inherits configuration from parent process if exists. options && options._loadedOptions && (forever.load(options._loadedOptions), delete options._loadedOptions); if (!started) { started = true; start(options); } });