mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
feat: cli command to toggle maintenance mode
This commit is contained in:
parent
42ac9cf922
commit
bb5d4ce9da
4 changed files with 48 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { GrantAdminCommand, PromptEmailQuestion, RevokeAdminCommand } from 'src/commands/grant-admin';
|
||||
import { ListUsersCommand } from 'src/commands/list-users.command';
|
||||
import { DisableMaintenanceModeCommand, EnableMaintenanceModeCommand } from 'src/commands/maintenance-mode';
|
||||
import {
|
||||
ChangeMediaLocationCommand,
|
||||
PromptConfirmMoveQuestions,
|
||||
|
|
@ -16,6 +17,8 @@ export const commandsAndQuestions = [
|
|||
PromptEmailQuestion,
|
||||
EnablePasswordLoginCommand,
|
||||
DisablePasswordLoginCommand,
|
||||
EnableMaintenanceModeCommand,
|
||||
DisableMaintenanceModeCommand,
|
||||
EnableOAuthLogin,
|
||||
DisableOAuthLogin,
|
||||
ListUsersCommand,
|
||||
|
|
|
|||
32
server/src/commands/maintenance-mode.ts
Normal file
32
server/src/commands/maintenance-mode.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { Command, CommandRunner } from 'nest-commander';
|
||||
import { CliService } from 'src/services/cli.service';
|
||||
|
||||
@Command({
|
||||
name: 'enable-maintenance-mode',
|
||||
description: 'Enable maintenance mode',
|
||||
})
|
||||
export class EnableMaintenanceModeCommand extends CommandRunner {
|
||||
constructor(private service: CliService) {
|
||||
super();
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
await this.service.enableMaintenanceMode();
|
||||
console.log("Maintenance mode has been enabled.\nThis change won't automatically propagate.");
|
||||
}
|
||||
}
|
||||
|
||||
@Command({
|
||||
name: 'disable-maintenance-mode',
|
||||
description: 'Disable maintenance mode',
|
||||
})
|
||||
export class DisableMaintenanceModeCommand extends CommandRunner {
|
||||
constructor(private service: CliService) {
|
||||
super();
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
await this.service.disableMaintenanceMode();
|
||||
console.log("Maintenance mode has been disabled.\nThis change won't automatically propagate.");
|
||||
}
|
||||
}
|
||||
|
|
@ -70,4 +70,4 @@ export const controllers = [
|
|||
ViewController,
|
||||
];
|
||||
|
||||
export const maintenanceControllers = [MaintenanceServerController];
|
||||
export const maintenanceControllers = [MaintenanceServerController, SystemConfigController];
|
||||
|
|
|
|||
|
|
@ -38,6 +38,18 @@ export class CliService extends BaseService {
|
|||
await this.updateConfig(config);
|
||||
}
|
||||
|
||||
async disableMaintenanceMode(): Promise<void> {
|
||||
const config = await this.getConfig({ withCache: false });
|
||||
config.maintenance.enabled = false;
|
||||
await this.updateConfig(config);
|
||||
}
|
||||
|
||||
async enableMaintenanceMode(): Promise<void> {
|
||||
const config = await this.getConfig({ withCache: false });
|
||||
config.maintenance.enabled = true;
|
||||
await this.updateConfig(config);
|
||||
}
|
||||
|
||||
async grantAdminAccess(email: string): Promise<void> {
|
||||
const user = await this.userRepository.getByEmail(email);
|
||||
if (!user) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue