UNPKG

1.02 kBJavaScriptView Raw
1"use strict";exports.__esModule=!0;var LarkLogger_1=require("@kemao/lark/Server/Log/LarkLogger/LarkLogger"),cp=require("child_process"),DebugServer=function(){function n(){}return n.run=function(e,r,t){void 0===t&&(t=null),null===n.SERVER?process.once("exit",function(){n.logger.log("进程退出",n.date),n.SERVER.kill("SIGTERM")}):(n.logger.log("进程重启"),n.SERVER.kill("SIGTERM"));var o=[];0<t&&o.push("--inspect="+t),o.push(e),(n.SERVER=cp.spawn("node",o,{cwd:r})).stdout.on("data",n.onStdOut),n.SERVER.stderr.on("data",function(e){return process.stderr.write(e)})},n.onStdOut=function(e){var r=e.toString("utf8").match(n.RUNNING_REGEXP);process.stdout.write(e),r&&(n.SERVER.stdout.removeListener("data",n.onStdOut),n.SERVER.stdout.on("data",function(e){return process.stdout.write(e)}),n.cb&&(n.cbIsPending=!1,n.cb(null,r[1])))},n.logger=new LarkLogger_1.LarkLogger("Task/RunServer"),n.SERVER=null,n.date=new Date,n.RUNNING_REGEXP=/The server is running at http:\/\/(.*?)\//,n}();exports.DebugServer=DebugServer;
\No newline at end of file