fix(restart): the self-relaunch waits for its parent's mutex
A database switch relaunches OpsLog, and the child regularly won the race against the old instance's teardown — so following the app's own instructions produced 'OpsLog is already running'. The relaunch now passes --relaunch, which gets the same 20-second mutex patience the post-update restart has always had. Opens the 0.27.6 block.
This commit is contained in:
@@ -48,14 +48,14 @@ func hasFlag(args []string, flag string) bool {
|
||||
}
|
||||
|
||||
// acquireInstance grabs the single-instance mutex. On a normal launch it's a plain
|
||||
// try (fail → another OpsLog is running, so exit). On a --post-update relaunch the
|
||||
// previous instance may still be shutting down and holding the mutex, so retry for
|
||||
// a few seconds until it frees.
|
||||
func acquireInstance(postUpdate bool) bool {
|
||||
// try (fail → another OpsLog is running, so exit). On a --post-update or
|
||||
// --relaunch start the previous instance may still be shutting down and holding
|
||||
// the mutex, so retry for a few seconds until it frees.
|
||||
func acquireInstance(wait bool) bool {
|
||||
if acquireSingleInstance() {
|
||||
return true
|
||||
}
|
||||
if !postUpdate {
|
||||
if !wait {
|
||||
return false
|
||||
}
|
||||
deadline := time.Now().Add(20 * time.Second)
|
||||
@@ -90,7 +90,11 @@ func main() {
|
||||
// to free instead of bailing out. Then clear the old exe it left behind.
|
||||
bootLogLaunch()
|
||||
postUpdate := hasFlag(os.Args[1:], "--post-update")
|
||||
if !acquireInstance(postUpdate) {
|
||||
// A self-relaunch (database switch) races its own parent: the new process
|
||||
// regularly wins the start against the old one's teardown, and the operator
|
||||
// got "OpsLog is already running" for following instructions. Same patience
|
||||
// as post-update.
|
||||
if !acquireInstance(postUpdate || hasFlag(os.Args[1:], "--relaunch")) {
|
||||
// SAID, not merely done. This exit is correct — a second instance would
|
||||
// fight the first over the rig — but it happened in total silence: no
|
||||
// window, no data folder, no log, which is indistinguishable from a
|
||||
|
||||
Reference in New Issue
Block a user