mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: loader: set addon prio
This commit is contained in:
1 parent
27ef93a1d0
commit
eaa03e594b
4 files changed
+17
-14
No files matched your search
@@ -7,6 +7,14 @@ const fs = require('fs-extra');
|
||||
const { argv } = require('yargs');
|
||||
const child = require('child_process');
|
||||
|
||||
function buildUrl(opts) {
|
||||
let mongourl = `${opts.protocol || 'mongodb'}://`;
|
||||
if (opts.username) mongourl += `${opts.username}:${opts.password}@`;
|
||||
mongourl += `${opts.host}:${opts.port}/${opts.name}`;
|
||||
if (opts.url) mongourl = opts.url;
|
||||
return mongourl;
|
||||
}
|
||||
|
||||
if (!cluster.isMaster) {
|
||||
const hydro = require('../dist/loader');
|
||||
// Forked by hydro
|
||||
@@ -22,13 +30,6 @@ if (!cluster.isMaster) {
|
||||
let addons = JSON.parse(fs.readFileSync(addonPath).toString());
|
||||
|
||||
if (argv._[0] === 'db') {
|
||||
function buildUrl(opts) {
|
||||
let mongourl = `${opts.protocol || 'mongodb'}://`;
|
||||
if (opts.username) mongourl += `${opts.username}:${opts.password}@`;
|
||||
mongourl += `${opts.host}:${opts.port}/${opts.name}`;
|
||||
if (opts.url) mongourl = opts.url;
|
||||
return mongourl;
|
||||
}
|
||||
const dbConfig = fs.readFileSync(path.resolve(hydroPath, 'config.json'), 'utf-8');
|
||||
const url = buildUrl(JSON.parse(dbConfig));
|
||||
return child.spawn('mongo', [url], { stdio: 'inherit' });
|
||||
|
||||
Reference in new issue
Block a user