From 14d976a12d036317bfecf70ac8794d6e9b6fd0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B05BEE13=2E=E5=8D=A2=E9=83=B4=E7=BE=A4?= Date: Tue, 24 Nov 2020 11:51:27 +0800 Subject: [PATCH] update --- src/bootstrap/worker.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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)) {