[英]How to run React Boilerplate with forever
I'm going to run react-boilerplate application forever in the server.我将永远在服务器中运行react-boilerplate应用程序。 I found forever and I'm not sure how I pass parameters to forever.
我找到了永远,我不确定如何将参数传递给永远。 The command to run server is like following:
运行服务器的命令如下:
PORT=80 npm run start:production
Seems like forever start PORT=80 npm run start:production
doesn't help me.似乎
forever start PORT=80 npm run start:production
对我没有帮助。
One thing is that PORT=80
part is setting the env variable, this kind of command should be in front of other commands.一件事是
PORT=80
部分是设置 env 变量,这种命令应该在其他命令之前。 The other thing is that to run npm scripts with forever, you need to use different syntax, so PORT=80 forever start -c "npm run start:production" /path/to/app/dir/
.另一件事是,要永久运行 npm 脚本,您需要使用不同的语法,因此
PORT=80 forever start -c "npm run start:production" /path/to/app/dir/
。
If you're running forever form the project folder, the path should be ./如果您从项目文件夹中永久运行,则路径应为 ./
Or you can run a react application with pm2 or with nohup或者您可以使用pm2或nohup运行反应应用程序
1) install pm2 globally 1)全局安装pm2
npm install pm2 -g
2) navigate to the project folder and execute, space is required after -- 2)导航到项目文件夹并执行,后面需要空格——
pm2 start npm -- start
3) to see running instances 3)查看正在运行的实例
pm2 ps
4) to see the other options 4)查看其他选项
pm2 --help
To run with nohup使用 nohup 运行
1) navigate to the project folder 1)导航到项目文件夹
nohup bash -c 'npm start' &
I'm going to run react-boilerplate application forever in the server.我将在服务器中永远运行react-boilerplate应用程序。 I found forever and I'm not sure how I pass parameters to forever.
我找到了永远,但不确定如何将参数永久传递给我。 The command to run server is like following:
运行服务器的命令如下所示:
PORT=80 npm run start:production
Seems like forever start PORT=80 npm run start:production
doesn't help me.好像
forever start PORT=80 npm run start:production
对我没有帮助。
pm2 is superb production process manager for Node. pm2 是 Node.js 的出色生产流程管理器。 In addition to starting and daemonizing any application, it has a built in load balancer.
除了启动和守护任何应用程序之外,它还有一个内置的负载平衡器。
Install pm2:安装pm2:
npm install pm2 -g
To add start and add deamon to your app, navigate to the app folder and:要向您的应用程序添加启动和添加守护程序,请导航到应用程序文件夹,然后:
pm2 start app.js
To make pm2 autoboot on server restart:在服务器重启时使 pm2 自动启动:
$ pm2 startup
Then copy and paste the code generated.然后复制并粘贴生成的代码。
Step 01: npm intsall -g forever
步骤 01:npm intsall -g 永远
Then, run PORT=<YOUR PORT> forever start -c "<command>" ./
然后,
PORT=<YOUR PORT> forever start -c "<command>" ./
运行PORT=<YOUR PORT> forever start -c "<command>" ./
- commands ex: "npm start" , "npm run dev" according to your requirement.
命令例如: "npm start" , "npm run dev" 根据您的要求。
- Note: ./ means you are in the project folder
注意:./ 表示您在项目文件夹中
- PORT=Your port number
PORT=您的端口号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.