(restart)
| 94 | } |
| 95 | |
| 96 | export async function shutdown(restart) { |
| 97 | let route = "/api/shutdown"; |
| 98 | if (restart) { |
| 99 | route = "/api/restart"; |
| 100 | } |
| 101 | return fetch(route, { |
| 102 | method: "POST", |
| 103 | headers: { |
| 104 | "X-CSRFToken": getCsrfToken(), |
| 105 | }, |
| 106 | mode: "same-origin", |
| 107 | cache: "no-cache", |
| 108 | redirect: "error", |
| 109 | }) |
| 110 | .then((httpResponse) => { |
| 111 | // A 502 usually means that nginx shutdown before it could process the |
| 112 | // response. Treat this as success. |
| 113 | if (httpResponse.status === 502) { |
| 114 | return; |
| 115 | } |
| 116 | return processJsonResponse(httpResponse); |
| 117 | }) |
| 118 | .catch((error) => { |
| 119 | // Depending on timing, the server may not respond to the shutdown |
| 120 | // request because it's shutting down. If we get a NetworkError, assume |
| 121 | // the shutdown succeeded. |
| 122 | if (error.message.indexOf("NetworkError") >= 0) { |
| 123 | return; |
| 124 | } |
| 125 | throw error; |
| 126 | }); |
| 127 | } |
| 128 | |
| 129 | export async function update() { |
| 130 | return fetch("/api/update", { |
nothing calls this directly
no test coverage detected