eggjs-note icon indicating copy to clipboard operation
eggjs-note copied to clipboard

请问 怎么把 eggjs 的npm run start 加入到 系统服务

Open mei2015 opened this issue 7 years ago • 12 comments

请问 怎么把 eggjs 的npm run start 加入到 系统服务

mei2015 avatar Apr 18 '19 01:04 mei2015

就是一个 shell,其他的该怎么加它就怎么加,没啥区别

atian25 avatar Apr 18 '19 01:04 atian25

我用的 node-window 但是。。

mei2015 avatar Apr 18 '19 01:04 mei2015

[图片]这个 地方的 script 怎么配置啊

mei2015 avatar Apr 18 '19 01:04 mei2015

https://blog.csdn.net/zzwwjjdj1/article/details/73483631

mei2015 avatar Apr 18 '19 01:04 mei2015

直接指向 node_modules/.bin/egg-scripts 或者自己写个 js 来 fork npm start

atian25 avatar Apr 18 '19 01:04 atian25

他是这样的 start: egg-script ... 主要是node-windows script 怎么写啊

mei2015 avatar Apr 18 '19 01:04 mei2015

直接指向 node_modules/.bin/egg-scripts 或者自己写个 js 来 fork npm start

大大 能给我 列子 不 刚接触 这块 不太明白 现在 要用

mei2015 avatar Apr 18 '19 02:04 mei2015

@mei2015 您好,你提出的问题很有意思,我一开始在学习egg.js时候也是第一反应在找怎用npm run start去启动。

因为egg.js本身对启动脚本做了封装,所以从初始化的脚手架是看不出传统Node应用npm run start的逻辑。

这里我之前写过一个最小demo, https://github.com/chenshenhai/eggjs-note/blob/master/demo/002-complete/index.js 使用egg 的node_module 替换里面的lib/egg,就可以直接用npm run start使用egg.js的核心服务能力。

chenshenhai avatar Apr 22 '19 13:04 chenshenhai

@atian25 惊现天猪大大,哈哈,很惭愧没时间把这本开源书写完 o(╯□╰)o

chenshenhai avatar Apr 22 '19 13:04 chenshenhai

不用那么复杂,就是写个 dispatch.js

// dispatch.js
const Command = require('egg-scripts');
new Command([
  'start', '--port=7001',
]).start();

atian25 avatar Apr 22 '19 14:04 atian25

@mei2015 您好,你提出的问题很有意思,我一开始在学习egg.js时候也是第一反应在找怎用npm run start去启动。

因为egg.js本身对启动脚本做了封装,所以从初始化的脚手架是看不出传统Node应用npm run start的逻辑。

这里我之前写过一个最小demo, https://github.com/chenshenhai/eggjs-note/blob/master/demo/002-complete/index.js 使用egg 的node_module 替换里面的lib/egg,就可以直接用npm run start使用egg.js的核心服务能力。

这个我知道 我是像加入到系统服务器 我用node-window 解决的

mei2015 avatar Apr 23 '19 01:04 mei2015

不用那么复杂,就是写个 dispatch.js

// dispatch.js
const Command = require('egg-scripts');
new Command([
  'start', '--port=7001',
]).start();

嗯 谢谢了 我解决了 还是用的 node-windows

mei2015 avatar Apr 23 '19 01:04 mei2015