让npm在linux后台运行,在Linux上同时执行多个npm自定义的命令,两个命令都是启动Node站点。并且在后台运行...

"start-client": "cross-env NODE_ENV=production node ./server/index.js",

"start-api": "cross-env NODE_ENV=production node ./server/api/index.js",

"start-pro": "concurrently \"npm run start-client\" \"npm run start-api\""

以上的npm run start-pro在linux上直接运行是可以跑起来的,但是关掉当前会话之后服务就存在了也就关闭了。

当我执行npm run start-pro &这个命令的时候,也正常的跑起来了,当我关闭会话之后,站点出现了503的错误,使用lsof -i:8080和lsof -i:8686查看端口是否存在,发现8080的端口不存在,但是8686的后端端口还存在。然后就放弃了这种操作。

当我执行nohup npm run start-pro &这个命令的时候,在项目的根目录出现了nohup.output的文件,里面记录了错误:

> p2@0.1.0 start-pro /website/pgyer

> concurrently "npm run start-client" "npm run start-api"

events.js:160

throw er; // Unhandled 'error' event

^

Error: EBADF: bad file descriptor, read

at Error (native)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! p2@0.1.0 start-pro: `concurrently "npm run start-client" "npm run start-api"`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the p2@0.1.0 start-pro script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! /root/.npm/_logs/2018-07-18T00_30_14_968Z-debug.log

再次想办法,使用先执行nohup npm run start-api &提示成功!在执行nobup npm run start-client &也执行成功!

本人比较强迫症,在这里想问一下,如何能一条命令一下执行npm run start-api和npm run start-client有什么方法吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值