重启功能

This commit is contained in:
undefined committed 2020-06-16 13:09:43 +08:00
1 parent a29b801e72
commit 2aeacb04ab
10 files changed
+49 -41

No files matched your search

+1
View File
@@ -103,6 +103,7 @@ async function lib(pending, fail) {
} catch (e) {
fail.push(i);
console.error(`Lib Load Fail: ${i}`);
console.error(e);
}
}
}
+5
View File
@@ -31,6 +31,11 @@ class SystemDashboardHandler extends SystemHandler {
this.response.template = 'manage_dashboard.html';
this.response.body.path.push(['manage_dashboard', null]);
}
async postRestart() {
process.send({ event: 'restart' });
this.back();
}
}
class SystemModuleHandler extends SystemHandler {
+4
View File
@@ -23,6 +23,8 @@ const Mark = require('markdown-it-mark');
// :::warn This page requires javascript. :::
// :::record-pass Accepted :::
const Container = require('markdown-it-container');
const Anchor = require('markdown-it-anchor');
const TOC = require('markdown-it-table-of-contents');
require('prismjs/components/index');
@@ -45,6 +47,8 @@ class Markdown extends MarkdownIt {
this.use(Imsize);
this.use(Footnote);
this.use(Mark);
this.use(Anchor);
this.use(TOC);
const RE_CONTAINER = /^(note|warn|record-pending|record-progress|record-fail|record-pass|record-ignored)\s+(.*)$/;
const CONTAINER_MAP = {
note: ['<blockquote class="note">', '</blockquote>'],
+21 -3
View File
@@ -20,6 +20,25 @@ async function entry(config) {
}
}
async function stopWorker() {
cluster.disconnect();
}
async function startWorker() {
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
}
async function messageHandler(worker, msg) {
if (msg.event && msg.event === 'restart') {
console.log('Restarting');
await stopWorker();
console.log('Worker stopped');
await startWorker();
}
}
async function load() {
global.nodeModules = {
bson: require('bson'),
@@ -65,9 +84,8 @@ async function load() {
cluster.on('online', (worker) => {
console.log(`Worker ${worker.process.pid} is online`);
});
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('message', messageHandler);
await startWorker();
} else {
console.log(`Worker ${process.pid} Starting`);
await entry({ entry: 'worker' });