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

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ package-lock.json
storage/ storage/
logs/ logs/
config/ config/
*.info

View File

@@ -2404,39 +2404,19 @@ var startMixIO = function() {
} }
var stopMixIO = function() { var stopMixIO = function() {
// kill 'mixio' process if it is running // try use pid.info to stop process
if (process.argv[0].indexOf("node") != -1) { try {
if (process.platform == "win32") { var pid = fs.readFileSync("pid.info", 'utf8')
console.log("Shutting down MixIO server...") if (pid != "") {
exec('taskkill /F /IM node.exe', function(err, stdout, stderr) { // convert to int
if (err) { pid = parseInt(pid)
console.log(err) process.kill(pid, 'SIGTERM')
} console.log("MixIO server with PID " + pid + " is stopped.")
})
} else { } else {
console.log("Shutting down MixIO server...") console.log("MixIO server is not running.")
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)
}
})
} }
} catch (e) {
console.log("MixIO server is not running.")
} }
} }
@@ -2516,6 +2496,10 @@ init(function(res) {
} }
}) })
} else if (args[0] == "debug") { } 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) { if (res) {
daemon_start() daemon_start()
startOnce() startOnce()

10
package-lock.json generated
View File

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

View File

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