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
parent
d1d2c4e5c9
commit
4dda515821
|
@ -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}` );
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"name": "Liza Server",
|
||||
"daemon": "../src/server/daemon/DevDaemon",
|
||||
|
||||
"pidfile": "",
|
||||
|
||||
"http": {
|
||||
"port": 8822
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue