mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
feat: cli command for maintenance mode closes #12293
This commit is contained in:
@@ -238,6 +238,12 @@ program
|
||||
.action(() => {
|
||||
require('./manage').info();
|
||||
});
|
||||
program
|
||||
.command('maintenance <toggle>')
|
||||
.description('Toggle maintenance mode true/false')
|
||||
.action((toggle) => {
|
||||
require('./manage').maintenance(toggle);
|
||||
});
|
||||
|
||||
// reset
|
||||
const resetCommand = program.command('reset');
|
||||
|
||||
@@ -191,6 +191,14 @@ async function info() {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
async function maintenance(toggle) {
|
||||
const turnOnMaintenance = toggle === 'true';
|
||||
await db.init();
|
||||
await db.setObjectField('config', 'maintenanceMode', turnOnMaintenance ? 1 : 0);
|
||||
console.log(`Maintenance mode turned ${turnOnMaintenance ? 'on' : 'off'}`);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
async function buildWrapper(targets, options) {
|
||||
try {
|
||||
await build.build(targets, options);
|
||||
@@ -207,3 +215,4 @@ exports.activate = activate;
|
||||
exports.listPlugins = listPlugins;
|
||||
exports.listEvents = listEvents;
|
||||
exports.info = info;
|
||||
exports.maintenance = maintenance;
|
||||
Reference in New Issue
Block a user