1
0
Fork 0

Account for absolute paths in configuration

* bin/server.js: Resolve absolute paths as such.
  (_resolvePath): Add function.
master
Mike Gerwitz 2017-09-14 15:44:09 -04:00
parent 4dda515821
commit 38539ca80b
1 changed files with 19 additions and 2 deletions

View File

@ -52,8 +52,8 @@ ConfLoader( fs, ConfStore )
] ) )
.then( ([ name, daemon, pidfile, conf ]) =>
{
const daemon_path = conf_dir + '/' + daemon;
const pid_path = conf_dir + '/' + ( pidfile || ".pid" );
const daemon_path = _resolvePath( conf_dir, daemon );
const pid_path = _resolvePath( conf_dir, ( pidfile || ".pid" ) );
writePidFile( pid_path );
greet( name, pid_path );
@ -66,6 +66,23 @@ ConfLoader( fs, ConfStore )
} );
/**
* Produce an absolute path if `path` is absolute, otherwise a path relative
* to the configuration directory
*
* @param {string} conf_path configuration path (for relative `path`)
* @param {string} path path to resolve
*
* @return resolved path
*/
function _resolvePath( conf_path, path )
{
return ( path[ 0 ] === '/' )
? path
: conf_path + '/' + path;
}
function writePidFile( pid_path )
{
fs.writeFile( pid_path, process.pid );