Correctly exit from web request
This commit is contained in:
+12
-9
@@ -627,24 +627,27 @@ namespace confighttp {
|
|||||||
|
|
||||||
print_req(request);
|
print_req(request);
|
||||||
|
|
||||||
// We do want to return here
|
BOOST_LOG(warning) << "Requested quit from config page!"sv;
|
||||||
std::thread quit_thread([]{
|
|
||||||
sleep(1000);
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// If we're running in a service, return a special status to
|
// If we're running in a service, return a special status to
|
||||||
// tell it to terminate too, otherwise it will just respawn us.
|
// tell it to terminate too, otherwise it will just respawn us.
|
||||||
if (GetConsoleWindow() == NULL) {
|
if (GetConsoleWindow() == NULL) {
|
||||||
lifetime::exit_sunshine(ERROR_SHUTDOWN_IN_PROGRESS, true);
|
lifetime::exit_sunshine(ERROR_SHUTDOWN_IN_PROGRESS, true);
|
||||||
return;
|
} else
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
lifetime::exit_sunshine(0, true);
|
lifetime::exit_sunshine(0, true);
|
||||||
});
|
}
|
||||||
|
|
||||||
quit_thread.detach();
|
|
||||||
|
|
||||||
|
// We do want to return here
|
||||||
|
// If user get a return, then the exit has failed.
|
||||||
|
// This might not be thread safe but we're exiting anyways
|
||||||
|
std::thread write_resp([response]{
|
||||||
|
sleep(5000);
|
||||||
response->write();
|
response->write();
|
||||||
|
});
|
||||||
|
write_resp.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -129,20 +129,17 @@ function removeCmd(index) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--hide_tray_controls-->
|
<!-- Hide Tray Controls -->
|
||||||
<div class="mb-3 form-check">
|
<div class="mb-3 form-check">
|
||||||
<input type="checkbox" class="form-check-input" id="hide_tray_controls" v-model="config.hide_tray_controls" true-value="enabled" false-value="disabled"/>
|
<input type="checkbox" class="form-check-input" id="hide_tray_controls" v-model="config.hide_tray_controls" true-value="enabled" false-value="disabled"/>
|
||||||
<label for="qp" class="form-check-label">{{ $t('config.hide_tray_controls') }}</label>
|
<label for="hide_tray_controls" class="form-check-label">{{ $t('config.hide_tray_controls') }}</label>
|
||||||
<div class="form-text">{{ $t('config.hide_tray_controls_desc') }}</div>
|
<div class="form-text">{{ $t('config.hide_tray_controls_desc') }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Notify Pre-Releases -->
|
<!-- Notify Pre-Releases -->
|
||||||
<div class="mb-3">
|
<div class="mb-3 form-check">
|
||||||
<label for="notify_pre_releases" class="form-label">{{ $t('config.notify_pre_releases') }}</label>
|
<input type="checkbox" class="form-check-input" id="notify_pre_releases" v-model="config.notify_pre_releases" true-value="enabled" false-value="disabled"/>
|
||||||
<select id="notify_pre_releases" class="form-select" v-model="config.notify_pre_releases">
|
<label for="notify_pre_releases" class="form-check-label">{{ $t('config.notify_pre_releases') }}</label>
|
||||||
<option value="disabled">{{ $t('_common.disabled') }}</option>
|
|
||||||
<option value="enabled">{{ $t('_common.enabled') }}</option>
|
|
||||||
</select>
|
|
||||||
<div class="form-text">{{ $t('config.notify_pre_releases_desc') }}</div>
|
<div class="form-text">{{ $t('config.notify_pre_releases_desc') }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -260,34 +260,17 @@
|
|||||||
quit() {
|
quit() {
|
||||||
if (window.confirm("Do you really want to quit Apollo? You'll not be able to start Apollo again if you have no other methods to operate your computer.")) {
|
if (window.confirm("Do you really want to quit Apollo? You'll not be able to start Apollo again if you have no other methods to operate your computer.")) {
|
||||||
this.serverQuitting = true;
|
this.serverQuitting = true;
|
||||||
const timeoutID = setTimeout(() => {
|
|
||||||
this.serverQuitting = false;
|
|
||||||
}, 5000);
|
|
||||||
fetch("/api/quit", {
|
fetch("/api/quit", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
clearTimeout(timeoutID);
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
fetch("/", {
|
|
||||||
signal: AbortSignal.timeout(1000)
|
|
||||||
}).then(() => {
|
|
||||||
reject();
|
|
||||||
}).catch(() => {
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.serverQuitting = false;
|
|
||||||
this.serverQuit = true;
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.serverQuitting = false;
|
this.serverQuitting = false;
|
||||||
this.serverQuit = false;
|
this.serverQuit = false;
|
||||||
alert("Exit failed!");
|
alert("Exit failed!");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.serverQuitting = false;
|
||||||
|
this.serverQuit = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user