Skip to content

Commit

Permalink
Merge pull request #304 from FlowFuse/restart-hang
Browse files Browse the repository at this point in the history
Ensure restart on done only a running NR instance
  • Loading branch information
knolleary authored Dec 13, 2024
2 parents 31ab49b + a80dc30 commit 4bbf9cd
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions lib/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,33 @@ class AdminInterface {
// response.status(409).send({err: "Not running"})
// }
} else if (request.body.cmd === 'restart') {
await launcher.stop()
setTimeout(async () => {
// Update the settings
if (launcher.state === States.RUNNING ||
launcher.state === States.CRASHED ||
launcher.state === States.SAFE
) {
await launcher.stop()
setTimeout(async () => {
// Update the settings
try {
await launcher.loadSettings()
await launcher.start(request.body.safe ? States.SAFE : States.RUNNING)
} catch (error) {
await launcher.logAuditEvent('start-failed', { error })
}
response.send({})
}, 2000)
} else if (launcher.state === States.STOPPED) {
try {
await launcher.loadSettings()
await launcher.start(request.body.safe ? States.SAFE : States.RUNNING)
} catch (error) {
await launcher.logAuditEvent('start-failed', { error })
}
response.send({})
}, 2000)
} else {
// Might need a different response
response.send({})
}
} else if (request.body.cmd === 'start') {
if (launcher.getState() === States.RUNNING) {
response.status(409).send({ err: 'Already running' })
Expand Down

0 comments on commit 4bbf9cd

Please sign in to comment.