fis-command-server
Advanced tools
Comparing version 0.7.0-beta5 to 0.7.0-beta6
@@ -15,4 +15,2 @@ var path = require('path'); | ||
if (process.platform === "win32") { | ||
var spawn = require('child_process').spawn; | ||
module.exports = function(options) { | ||
@@ -28,10 +26,7 @@ options = mixin(mixin({}, defaultOptions), options); | ||
var execPath = process.execPath; | ||
var createProcess = function() { | ||
var argsRaw = process.argv.concat(); | ||
var argv = process.argv.slice(1); | ||
argsRaw.shift(); | ||
argsRaw.unshift(options.exec); | ||
worker = spawn(execPath, argsRaw, { | ||
worker = require('child_process').fork(options.exec, argv, { | ||
silent: true, | ||
detached: true | ||
@@ -76,4 +71,4 @@ }); | ||
var killProcess = function(signal) { | ||
worker.kill('SIGTERM'); | ||
var killProcess = function(cb) { | ||
require('child_process').exec('taskkill /PID ' + worker.pid + ' /T /F', cb); | ||
} | ||
@@ -85,8 +80,9 @@ | ||
respawn = false; | ||
killProcess('SIGTERM'); | ||
logger.write('The master get killed!'); | ||
process.exit(); | ||
killProcess(function() { | ||
logger.write('The master get killed!'); | ||
process.exit(); | ||
}); | ||
} | ||
process.on('SIGTERM', killSelf); | ||
process.on('exit', killSelf); | ||
@@ -102,4 +98,3 @@ // watch server scripts modification, so we can gracefully restarts the server. | ||
logger.write('Server scripts changed, now will restart server.'); | ||
killProcess('SIGTERM'); | ||
createProcess(); | ||
killProcess(); | ||
}); | ||
@@ -106,0 +101,0 @@ } |
@@ -74,2 +74,4 @@ /** | ||
var tmp = _.getPidFile(); | ||
var isWin = fis.util.isWin(); | ||
//read option | ||
@@ -82,5 +84,12 @@ var opt = option(); | ||
if (exists) { | ||
// try to gracefully kill it. | ||
process.kill(pid, 'SIGTERM'); | ||
if (isWin) { | ||
// windows 貌似没有 gracefully 关闭。 | ||
// 用 process.kill 会遇到进程关不了的情况,没有 exit 事件响应,原因不明! | ||
require('child_process').exec('taskkill /PID ' + pid + ' /T /F'); | ||
} else { | ||
// try to gracefully kill it. | ||
process.kill(pid, 'SIGTERM'); | ||
} | ||
// checkout it every half second. | ||
@@ -97,3 +106,5 @@ (function(done) { | ||
try { | ||
process.kill(pid, 'SIGKILL'); | ||
isWin ? | ||
require('child_process').exec('taskkill /PID ' + pid + ' /T /F') : | ||
process.kill(pid, 'SIGKILL'); | ||
} catch(e) { | ||
@@ -278,2 +289,1 @@ | ||
} | ||
{ | ||
"name": "fis-command-server", | ||
"description": "fis server command.", | ||
"version": "0.7.0-beta5", | ||
"version": "0.7.0-beta6", | ||
"author": "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "http://fis.baidu.com/", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4933732
1018
9