mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-03 22:49:03 +02:00
fixing bug where sometimes a pidfile was left over, and nodebb would refuse to start a daemon again.
This commit is contained in:
11
loader.js
11
loader.js
@@ -44,11 +44,18 @@ var nconf = require('nconf'),
|
||||
|
||||
nconf.argv();
|
||||
|
||||
// Start the daemon!
|
||||
if (nconf.get('d')) {
|
||||
// Check for a still-active NodeBB process
|
||||
if (fs.existsSync(pidFilePath)) {
|
||||
console.log('\n Error: Another NodeBB is already running!');
|
||||
process.exit();
|
||||
try {
|
||||
var pid = fs.readFileSync(pidFilePath, { encoding: 'utf-8' });
|
||||
process.kill(pid, 0);
|
||||
console.log('\n Error: Another NodeBB is already running!');
|
||||
process.exit();
|
||||
} catch (e) {
|
||||
fs.unlinkSync(pidFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise logging streams
|
||||
|
||||
Reference in New Issue
Block a user