1
0
Fork 0

conf: Specify relative/absolute path to daemon

This isn't ideal, but will allow using daemons classes from anywhere
on disk.

* bin/server.js: Interpret daemon path as relative to conf file path.
* conf/vanilla-server.json: Use relative path to `DevDaemon'.
master
Mike Gerwitz 2017-09-08 14:18:16 -04:00
parent 73354e39d0
commit ed7e5fc547
2 changed files with 9 additions and 6 deletions

View File

@ -21,7 +21,8 @@
'use strict'; 'use strict';
const fs = require( 'fs' ); const fs = require( 'fs' );
const path = require( 'path' );
const { const {
conf: { conf: {
@ -39,6 +40,7 @@ const conf_path = (
: '' : ''
) || __dirname + '/../conf/vanilla-server.json'; ) || __dirname + '/../conf/vanilla-server.json';
const conf_dir = path.dirname( conf_path );
ConfLoader( fs, ConfStore ) ConfLoader( fs, ConfStore )
.fromFile( conf_path ) .fromFile( conf_path )
@ -49,8 +51,10 @@ ConfLoader( fs, ConfStore )
] ) ) ] ) )
.then( ([ name, daemon, conf ]) => .then( ([ name, daemon, conf ]) =>
{ {
greet( name, daemon ); const daemon_path = conf_dir + '/' + daemon;
return server.daemon[ daemon ]( conf ).start();
greet( name );
return require( daemon_path )( conf ).start();
} ) } )
.catch( e => { .catch( e => {
console.error( e.stack ); console.error( e.stack );
@ -58,9 +62,8 @@ ConfLoader( fs, ConfStore )
} ); } );
function greet( name, daemon ) function greet( name )
{ {
console.log( `${name} (liza-${version})`); console.log( `${name} (liza-${version})`);
console.log( `Server configuration: ${conf_path}` ); console.log( `Server configuration: ${conf_path}` );
console.log( `Starting with ${daemon}, pid ${process.pid}` );
} }

View File

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