diff --git a/src/bootstrap/worker.js b/src/bootstrap/worker.js index 75f49ed..c3645e4 100644 --- a/src/bootstrap/worker.js +++ b/src/bootstrap/worker.js @@ -1,11 +1,15 @@ // invoked in worker const { execSync } = require('child_process'); +const os = require("os"); think.beforeStartServer(async () => { - try { - execSync('service mysql start', { stdio: ['inherit', 'inherit', 'inherit'] }); - } catch (error) { - console.log("beforeStartServer", error); + if (os.platform().startsWith("linux")) { + try { + execSync('service mysql start', { stdio: ['inherit', 'inherit', 'inherit'] }); + } catch (error) { + console.log("beforeStartServer", error); + } } + const username = 'test'; let user = await think.model("users").where({ username }).find(); if (think.isEmpty(user)) {