"start-client":"cross-envNODE_ENV=productionnode./server/index.js","start-api":"cross-envNODE_ENV=productionnode./server/api/index.js","start-pro":"concurrently\"npmrunstart-client\"\"npmrunstart-api\""以上的npmrunstart-pro在linux上直接運(yùn)行是可以跑起來的,但是關(guān)掉當(dāng)前會話之后服務(wù)就存在了也就關(guān)閉了。當(dāng)我執(zhí)行npmrunstart-pro&這個命令的時候,也正常的跑起來了,當(dāng)我關(guān)閉會話之后,站點(diǎn)出現(xiàn)了503的錯誤,使用lsof-i:8080和lsof-i:8686查看端口是否存在,發(fā)現(xiàn)8080的端口不存在,但是8686的后端端口還存在。然后就放棄了這種操作。當(dāng)我執(zhí)行nohupnpmrunstart-pro&這個命令的時候,在項(xiàng)目的根目錄出現(xiàn)了nohup.output的文件,里面記錄了錯誤:>p2@0.1.0start-pro/website/pgyer>concurrently"npmrunstart-client""npmrunstart-api"events.js:160thrower;//Unhandled'error'event^Error:EBADF:badfiledescriptor,readatError(native)npmERR!codeELIFECYCLEnpmERR!errno1npmERR!p2@0.1.0start-pro:`concurrently"npmrunstart-client""npmrunstart-api"`npmERR!Exitstatus1npmERR!npmERR!Failedatthep2@0.1.0start-proscript.npmERR!Thisisprobablynotaproblemwithnpm.Thereislikelyadditionalloggingoutputabove.npmERR!Acompletelogofthisruncanbefoundin:npmERR!/root/.npm/_logs/2018-07-18T00_30_14_968Z-debug.log再次想辦法,使用先執(zhí)行nohupnpmrunstart-api&提示成功!在執(zhí)行nobupnpmrunstart-client&也執(zhí)行成功!本人比較強(qiáng)迫癥,在這里想問一下,如何能一條命令一下執(zhí)行npmrunstart-api和npmrunstart-client有什么方法嗎?
在Linux上同時執(zhí)行多個npm自定義的命令,兩個命令都是啟動Node站點(diǎn)。并且在后臺運(yùn)行
冉冉說
2019-05-13 07:56:06