log-pid-to-kill

This commit is contained in:
unknown
2025-05-14 10:49:24 +08:00
parent 763f2a7597
commit 0cf8bc9ca9
4 changed files with 23 additions and 38 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ node_modules/
package-lock.json
storage/
logs/
config/
config/
*.info

View File

@@ -2404,39 +2404,19 @@ var startMixIO = function() {
}
var stopMixIO = function() {
// kill 'mixio' process if it is running
if (process.argv[0].indexOf("node") != -1) {
if (process.platform == "win32") {
console.log("Shutting down MixIO server...")
exec('taskkill /F /IM node.exe', function(err, stdout, stderr) {
if (err) {
console.log(err)
}
})
// try use pid.info to stop process
try {
var pid = fs.readFileSync("pid.info", 'utf8')
if (pid != "") {
// convert to int
pid = parseInt(pid)
process.kill(pid, 'SIGTERM')
console.log("MixIO server with PID " + pid + " is stopped.")
} else {
console.log("Shutting down MixIO server...")
exec('pkill node', function(err, stdout, stderr) {
if (err) {
console.log(err)
}
})
}
} else {
if (process.platform == "win32") {
console.log("Shutting down MixIO server...")
exec('taskkill /F /IM mixio.exe', function(err, stdout, stderr) {
if (err) {
console.log(err)
}
})
} else {
console.log("Shutting down MixIO server...")
exec('pkill mixio', function(err, stdout, stderr) {
if (err) {
console.log(err)
}
})
console.log("MixIO server is not running.")
}
} catch (e) {
console.log("MixIO server is not running.")
}
}
@@ -2516,6 +2496,10 @@ init(function(res) {
}
})
} else if (args[0] == "debug") {
// 记录当前的进程ID
console.log("[INFO] MixIO server is running with PID " + process.pid)
// 输出到当前目录下的pid.info文件
fs.writeFileSync("pid.info", "" + process.pid)
if (res) {
daemon_start()
startOnce()

10
package-lock.json generated
View File

@@ -9,7 +9,7 @@
"version": "1.10.0",
"dependencies": {
"aedes": "^0.51.3",
"axios": "^0.27.0",
"axios": "^0.27.2",
"cors": "^2.8.5",
"ejs": "^3.1.10",
"express": "^4.21.2",
@@ -854,10 +854,10 @@
"license": "MIT"
},
"node_modules/axios": {
"version": "0.27.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.0.tgz",
"integrity": "sha512-XV/WrPxXfzgZ8j4lcB5i6LyaXmi90yetmV/Fem0kmglGx+mpY06CiweL3YxU6wOTNLmqLUePW4G8h45nGZ/+pA==",
"deprecated": "Formdata complete broken, incorrect build size",
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"

View File

@@ -1,7 +1,7 @@
{
"dependencies": {
"aedes": "^0.51.3",
"axios": "^0.27.0",
"axios": "^0.27.2",
"cors": "^2.8.5",
"ejs": "^3.1.10",
"express": "^4.21.2",