mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Prevent shutdown running more than once
Exit immediately if shutdown has already been called. This is due to the possibility of it being called multiple times from combinations of signals and fatal errors.
This commit is contained in:
1 parent
99fa6b4b12
commit
4ca092f351
2 files changed
+9
-1
No files matched your search
@@ -477,11 +477,16 @@ async function saveUsers(databaseDirectory, file) {
|
|||||||
await fs.outputFile(filePath, JSON.stringify(serialized, null, 4));
|
await fs.outputFile(filePath, JSON.stringify(serialized, null, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let shuttingDown = false;
|
||||||
/**
|
/**
|
||||||
* Innitiate shutdown of master server
|
* Innitiate shutdown of master server
|
||||||
*/
|
*/
|
||||||
async function shutdown() {
|
async function shutdown() {
|
||||||
logger.info("Shutting down");
|
if (shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
shuttingDown = true;
|
||||||
|
|
||||||
let exitStartTime = Date.now();
|
let exitStartTime = Date.now();
|
||||||
try {
|
try {
|
||||||
logger.info("Saving configs");
|
logger.info("Saving configs");
|
||||||
|
|||||||
@@ -1384,6 +1384,9 @@ class Slave extends libLink.Link {
|
|||||||
* Stops all instances and closes the connection
|
* Stops all instances and closes the connection
|
||||||
*/
|
*/
|
||||||
async shutdown() {
|
async shutdown() {
|
||||||
|
if (this._shuttingDown) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._shuttingDown = true;
|
this._shuttingDown = true;
|
||||||
this.connector.setTimeout(30);
|
this.connector.setTimeout(30);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user