mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 09:36:08 +08:00
重启功能
This commit is contained in:
1 parent
a29b801e72
commit
2aeacb04ab
10 files changed
+49
-41
No files matched your search
@@ -103,6 +103,7 @@ async function lib(pending, fail) {
|
||||
} catch (e) {
|
||||
fail.push(i);
|
||||
console.error(`Lib Load Fail: ${i}`);
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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' });
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const child = require('child_process');
|
||||
|
||||
const appPath = path.resolve(__dirname, '..', 'hydro', 'development.js');
|
||||
|
||||
const app = child.fork(appPath);
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"id": "html2md",
|
||||
"version": "0.0.1",
|
||||
"description": "Convert html to markdown"
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
const RE_IMG = /<img.*?src="(.*?)".*?>(.*?)<\/img>/i;
|
||||
const RE_A = /<a.*?href="(.*?)".*?>(.*?)<\/a>/i;
|
||||
const RE_BLOCKQUOTE = /<blockquote.*?>(.*?)<\/blockquote>/i;
|
||||
|
||||
function replacer(RE, cb) { // eslint-disable-line no-unused-vars
|
||||
// eslint-disable-next-line no-eval
|
||||
return eval(`(substr)=>{
|
||||
const s = RE.exec(substr);
|
||||
return cb(s);
|
||||
}`);
|
||||
}
|
||||
|
||||
function html2md(str) {
|
||||
return str.replace(/<p>/gmi, '').replace(/<\/p>/gmi, ' ')
|
||||
.replace(/<h[1-6]>/gmi, (substr) => {
|
||||
const s = /<h[1-6]>/i.exec(substr);
|
||||
return `${'#'.repeat(parseInt(s[1]))} `;
|
||||
})
|
||||
.replace(/<\/h[0-6]>/, '\n')
|
||||
.replace(/<\/?code>/, '\n```\n')
|
||||
.replace(/<img.*?src=".*?".*?>.*?<\/img>/gmi, replacer(RE_IMG, (s) => `![${s[2]}](${s[1]})`))
|
||||
.replace(/<a.*?href=".*?".*?>.*?<\/a>/gmi, replacer(RE_A, (s) => `[${s[2]}](${s[1]})`))
|
||||
.replace(/<blockquote.*?>.*?<\/blockquote>/gmi, replacer(RE_BLOCKQUOTE, (s) => `> ${s[1]}`));
|
||||
}
|
||||
|
||||
global.Hydro.lib.html2md = module.exports = html2md;
|
||||
@@ -17,11 +17,13 @@
|
||||
"koa-static-cache": "^5.1.3",
|
||||
"lodash": "^4.17.15",
|
||||
"markdown-it": "^10.0.0",
|
||||
"markdown-it-anchor": "^5.3.0",
|
||||
"markdown-it-container": "^3.0.0",
|
||||
"markdown-it-footnote": "^3.0.2",
|
||||
"markdown-it-imsize": "^2.0.1",
|
||||
"markdown-it-katex": "^2.0.3",
|
||||
"markdown-it-mark": "^3.0.0",
|
||||
"markdown-it-table-of-contents": "^0.4.4",
|
||||
"moment-timezone": "^0.5.31",
|
||||
"mongodb": "^3.5.7",
|
||||
"nodemailer": "^6.3.1",
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
<div class="section">
|
||||
<div class="section__header">
|
||||
<h1 class="section__title" data-heading>{{ _('Information') }}</h1>
|
||||
<div class="section__tools">
|
||||
<form method="post">
|
||||
<input type="hidden" name="operation" value="restart">
|
||||
<button type="submit" class="primary rounded button"><span class="icon icon-refresh"></span> {{ _('Restart') }}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section__body typo">
|
||||
<dl class="large horizontal">
|
||||
|
||||
@@ -2433,6 +2433,11 @@ map-visit@^1.0.0:
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
markdown-it-anchor@^5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz#d549acd64856a8ecd1bea58365ef385effbac744"
|
||||
integrity sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==
|
||||
|
||||
markdown-it-container@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-container/-/markdown-it-container-3.0.0.tgz#1d19b06040a020f9a827577bb7dbf67aa5de9a5b"
|
||||
@@ -2460,6 +2465,11 @@ markdown-it-mark@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-mark/-/markdown-it-mark-3.0.0.tgz#27c3e39ef3cc310b2dde5375082c9fa912983cda"
|
||||
integrity sha512-HqMWeKfMMOu4zBO0emmxsoMWmbf2cPKZY1wP6FsTbKmicFfp5y4L3KXAsNeO1rM6NTJVOrNlLKMPjWzriBGspw==
|
||||
|
||||
markdown-it-table-of-contents@^0.4.4:
|
||||
version "0.4.4"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it-table-of-contents/-/markdown-it-table-of-contents-0.4.4.tgz#3dc7ce8b8fc17e5981c77cc398d1782319f37fbc"
|
||||
integrity sha512-TAIHTHPwa9+ltKvKPWulm/beozQU41Ab+FIefRaQV1NRnpzwcV9QOe6wXQS5WLivm5Q/nlo0rl6laGkMDZE7Gw==
|
||||
|
||||
markdown-it@^10.0.0:
|
||||
version "10.0.0"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc"
|
||||
|
||||
Reference in new issue
Block a user