core: loader: set addon prio

This commit is contained in:
undefined committed 2021-05-24 22:06:12 +08:00
1 parent 27ef93a1d0
commit eaa03e594b
4 files changed
+17 -14

No files matched your search

+8 -7
View File
@@ -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' });