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
parent
73354e39d0
commit
ed7e5fc547
|
@ -21,7 +21,8 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const fs = require( 'fs' );
|
||||
const fs = require( 'fs' );
|
||||
const path = require( 'path' );
|
||||
|
||||
const {
|
||||
conf: {
|
||||
|
@ -39,6 +40,7 @@ const conf_path = (
|
|||
: ''
|
||||
) || __dirname + '/../conf/vanilla-server.json';
|
||||
|
||||
const conf_dir = path.dirname( conf_path );
|
||||
|
||||
ConfLoader( fs, ConfStore )
|
||||
.fromFile( conf_path )
|
||||
|
@ -49,8 +51,10 @@ ConfLoader( fs, ConfStore )
|
|||
] ) )
|
||||
.then( ([ name, daemon, conf ]) =>
|
||||
{
|
||||
greet( name, daemon );
|
||||
return server.daemon[ daemon ]( conf ).start();
|
||||
const daemon_path = conf_dir + '/' + daemon;
|
||||
|
||||
greet( name );
|
||||
return require( daemon_path )( conf ).start();
|
||||
} )
|
||||
.catch( e => {
|
||||
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( `Server configuration: ${conf_path}` );
|
||||
console.log( `Starting with ${daemon}, pid ${process.pid}` );
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Liza Server",
|
||||
"daemon": "DevDaemon",
|
||||
"daemon": "../src/server/daemon/DevDaemon",
|
||||
|
||||
"http": {
|
||||
"port": 8822
|
||||
|
|
Loading…
Reference in New Issue