1
0
Fork 0

Re-add pidfile

Configurable via the `pidfile' config option.

* bin/server.js: Accept `pidfile' config.  Include path in greeting.
  (writePidFile): Write to `pidfile' and unlink after exit.
* conf/vanilla-server.json (pidfile): Add configuration key.
master
Mike Gerwitz 2017-09-12 15:29:43 -04:00
parent d1d2c4e5c9
commit 4dda515821
2 changed files with 18 additions and 3 deletions

View File

@ -47,13 +47,17 @@ ConfLoader( fs, ConfStore )
.then( conf => Promise.all( [
conf.get( 'name' ),
conf.get( 'daemon' ),
conf.get( 'pidfile' ),
Promise.resolve( conf ),
] ) )
.then( ([ name, daemon, conf ]) =>
.then( ([ name, daemon, pidfile, conf ]) =>
{
const daemon_path = conf_dir + '/' + daemon;
const pid_path = conf_dir + '/' + ( pidfile || ".pid" );
writePidFile( pid_path );
greet( name, pid_path );
greet( name );
return require( daemon_path )( conf ).start();
} )
.catch( e => {
@ -62,8 +66,17 @@ ConfLoader( fs, ConfStore )
} );
function greet( name )
function writePidFile( pid_path )
{
fs.writeFile( pid_path, process.pid );
process.on( 'exit', () => fs.unlink( pid_path ) );
}
function greet( name, pid_path )
{
console.log( `${name} (liza-${version})`);
console.log( `Server configuration: ${conf_path}` );
console.log( `PID file: ${pid_path}` );
}

View File

@ -2,6 +2,8 @@
"name": "Liza Server",
"daemon": "../src/server/daemon/DevDaemon",
"pidfile": "",
"http": {
"port": 8822
},