[英]How to run React Boilerplate with forever
我將永遠在服務器中運行react-boilerplate應用程序。 我找到了永遠,我不確定如何將參數傳遞給永遠。 運行服務器的命令如下:
PORT=80 npm run start:production
似乎forever start PORT=80 npm run start:production
對我沒有幫助。
一件事是PORT=80
部分是設置 env 變量,這種命令應該在其他命令之前。 另一件事是,要永久運行 npm 腳本,您需要使用不同的語法,因此PORT=80 forever start -c "npm run start:production" /path/to/app/dir/
。
如果您從項目文件夾中永久運行,則路徑應為 ./
或者您可以使用pm2或nohup運行反應應用程序
1)全局安裝pm2
npm install pm2 -g
2)導航到項目文件夾並執行,后面需要空格——
pm2 start npm -- start
3)查看正在運行的實例
pm2 ps
4)查看其他選項
pm2 --help
使用 nohup 運行
1)導航到項目文件夾
nohup bash -c 'npm start' &
我將在服務器中永遠運行react-boilerplate應用程序。 我找到了永遠,但不確定如何將參數永久傳遞給我。 運行服務器的命令如下所示:
PORT=80 npm run start:production
好像forever start PORT=80 npm run start:production
對我沒有幫助。
pm2 是 Node.js 的出色生產流程管理器。 除了啟動和守護任何應用程序之外,它還有一個內置的負載平衡器。
安裝pm2:
npm install pm2 -g
要向您的應用程序添加啟動和添加守護程序,請導航到應用程序文件夾,然后:
pm2 start app.js
在服務器重啟時使 pm2 自動啟動:
$ pm2 startup
然后復制並粘貼生成的代碼。
步驟 01:npm intsall -g 永遠
然后, PORT=<YOUR PORT> forever start -c "<command>" ./
運行PORT=<YOUR PORT> forever start -c "<command>" ./
- 命令例如: "npm start" , "npm run dev" 根據您的要求。
- 注意:./ 表示您在項目文件夾中
- PORT=您的端口號
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.