Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure restart on done only a running NR instance #304

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading