Skip to content

Commit

Permalink
fix pidPath on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Apr 7, 2018
1 parent 272822c commit 7cfe54b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
42 changes: 21 additions & 21 deletions cli/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,28 @@ const setup = function setup() {
};
var child = new(forever.Monitor)(path.join(__dirname, '..', 'app.js'), foreverOptions);
if (options.action == "start") {
try {
fs.appendFileSync(pidpath, process.pid+'|');
child.start();
} catch (piderr) {
console.error('failed to start microgateway: ' + piderr);
process.exit(1);
}
try {
fs.appendFileSync(pidpath, process.pid + '|');
child.start();
} catch (piderr) {
console.error('failed to start microgateway: ' + piderr);
process.exit(1);
}
} else {
try {
var pids = fs.readFileSync(pidpath,'utf8').split('|');
if (pids) {
pids.forEach(function(pid){
process.kill(parseInt(pid), 'SIGINT');
});
fs.unlinkSync(pidpath);
} else {
console.log('pid file not found. please run this command from the folder where microgateway was started.')
}
} catch (piderr) {
console.error('failed to stop microgateway: ' + piderr);
process.exit(1);
}
try {
var pids = fs.readFileSync(pidpath, 'utf8').split('|');
if (pids) {
pids.forEach(function(pid) {
process.kill(parseInt(pid), 'SIGINT');
});
fs.unlinkSync(pidpath);
} else {
console.log('pid file not found. please run this command from the folder where microgateway was started.')
}
} catch (piderr) {
console.error('failed to stop microgateway: ' + piderr);
process.exit(1);
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion cli/lib/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Gateway.prototype.start = (options) => {
if (!isWin) {
console.log('Removing the socket file as part of cleanup');
fs.unlinkSync(ipcPath);
fs.unlinkSync(pidPath)
}
fs.unlinkSync(pidPath);
});

process.on('SIGTERM', () => {
Expand Down
7 changes: 1 addition & 6 deletions config/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ module.exports = {
}
},
getPIDFilePath: function getPIDFilePath() {
if (!isWin) {
return path.join(process.cwd(), defaultIPCFileName + '.pid');
} else {
return path.join('\\\\?\\pipe', process.cwd(), defaultIPCFileName+'.pid');
}

return path.join(process.cwd(), defaultIPCFileName + '.pid');
},
homeDir: homeDir,
defaultDir: configDir,
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edgemicro",
"version": "2.5.15",
"version": "2.5.16",
"description": "Apigee Edge Microgateway",
"main": "index.js",
"license": "Apache-2.0",
Expand Down

0 comments on commit 7cfe54b

Please sign in to comment.