MCPcopy Index your code
hub / github.com/tiny-pilot/tinypilot / shutdown

Function shutdown

app/static/js/controllers.js:96–127  ·  view source on GitHub ↗
(restart)

Source from the content-addressed store, hash-verified

94}
95
96export 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
129export async function update() {
130 return fetch("/api/update", {

Callers

nothing calls this directly

Calls 2

getCsrfTokenFunction · 0.85
processJsonResponseFunction · 0.85

Tested by

no test coverage detected