1 | const util = require('util');
|
2 | const common = require('@screeps/common');
|
3 | const config = common.configManager.config;
|
4 | const C = config.common.constants;
|
5 | const db = common.storage.db;
|
6 | const env = common.storage.env;
|
7 | const pubsub = common.storage.pubsub;
|
8 | const q = require('q');
|
9 | const fs = require('fs');
|
10 | const _ = require('lodash');
|
11 | const zlib = require('zlib');
|
12 | const utils = require('../utils');
|
13 | const path = require('path');
|
14 |
|
15 | exports.resetAllData = utils.withHelp([
|
16 | "resetAllData() - Wipe all world data and reset the database to the default state.",
|
17 | function resetAllData() {
|
18 | return common.storage.resetAllData();
|
19 | }
|
20 | ]);
|
21 |
|
22 | exports.sendServerMessage = utils.withHelp([
|
23 | 'sendServerMessage(message) - Send a text server message to all currently connected players.',
|
24 | function sendServerMessage(message) {
|
25 | return pubsub.publish('serverMessage', message);
|
26 | }
|
27 | ]);
|
28 |
|
29 | exports.pauseSimulation = utils.withHelp([
|
30 | 'pauseSimulation() - Stop main simulation loop execution.',
|
31 | function pauseSimulation() {
|
32 | return env.set(env.keys.MAIN_LOOP_PAUSED, '1').then(() => 'OK');
|
33 | }
|
34 | ]);
|
35 |
|
36 | exports.resumeSimulation = utils.withHelp([
|
37 | 'resumeSimulation() - Resume main simulation loop execution.',
|
38 | function resumeSimulation() {
|
39 | return env.set(env.keys.MAIN_LOOP_PAUSED, '0').then(() => 'OK');
|
40 | }
|
41 | ]);
|
42 |
|
43 | exports.runCronjob = utils.withHelp([
|
44 | 'runCronjob(jobName) - Run a cron job immediately.',
|
45 | function runCronjob(jobName) {
|
46 | if(!config.cronjobs[jobName]) {
|
47 | return q.reject(`Cronjob "${jobName}" not found`);
|
48 | }
|
49 |
|
50 | return q.when(config.cronjobs[jobName][1]()).then(() => 'OK');
|
51 | }
|
52 | ]);
|
53 |
|
54 | exports._help = utils.generateCliHelp('system.', exports); |
\ | No newline at end of file |