项目自启动服务

This commit is contained in:
B05BEE13.卢郴群 2020-11-23 13:53:49 +08:00
parent 597052515c
commit c0e3af63c1
1 changed files with 6 additions and 0 deletions

View File

@ -1,5 +1,11 @@
// invoked in worker // invoked in worker
const { execSync } = require('child_process');
think.beforeStartServer(async () => { think.beforeStartServer(async () => {
try {
execSync('service mysql start', { stdio: ['inherit', 'inherit', 'inherit'] });
} catch (error) {
console.log("beforeStartServer", error);
}
const username = 'test'; const username = 'test';
let user = await think.model("users").where({ username }).find(); let user = await think.model("users").where({ username }).find();
if (think.isEmpty(user)) { if (think.isEmpty(user)) {