mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
FlexServer: add new admin restart endpoint
This adds an endpoint for the admin user to be able to signal to a controlling process to restart the server. This is intended for `docker-runner.mjs`.
This commit is contained in:
parent
2cb38709a5
commit
20035fd58f
@ -1883,6 +1883,22 @@ export class FlexServer implements GristServer {
|
||||
const probes = new BootProbes(this.app, this, '/api', adminMiddleware);
|
||||
probes.addEndpoints();
|
||||
|
||||
this.app.post('/api/admin/restart', requireInstallAdmin, expressWrap(async (req, resp) => {
|
||||
const newConfig = req.body.newConfig;
|
||||
resp.on('finish', () => {
|
||||
// If we have IPC with parent process (e.g. when running under
|
||||
// Docker) tell the parent that we have a new environment so it
|
||||
// can restart us.
|
||||
if (process.send) {
|
||||
process.send({ action: 'restart', newConfig });
|
||||
}
|
||||
});
|
||||
// On the topic of http response codes, thus spake MDN:
|
||||
// "409: This response is sent when a request conflicts with the current state of the server."
|
||||
const status = process.send ? 200 : 409;
|
||||
return resp.status(status).send();
|
||||
}));
|
||||
|
||||
// Restrict this endpoint to install admins
|
||||
this.app.get('/api/install/prefs', requireInstallAdmin, expressWrap(async (_req, resp) => {
|
||||
const activation = await this._activations.current();
|
||||
|
Loading…
Reference in New Issue
Block a user