How to start Reactjs application with PM2 as a service (Linux & MacOS)

1. First install PM2 using any of these commands —

$ npm install [email protected] -g<br /># or<br />$ yarn global add pm2
Code language: HTML, XML (xml)

Remember to use option -g or global. You need to install it globally.

2. Once installation is done run below command –

$ pm2 list
Code language: PHP (php)

List command list down all the applications running under PM2. If your PM2 installation was successful then above command should display a output like this —

Since right now there is no running process under PM2, list is empty.

3. Now from command prompt navigate inside your project’s root folder and run below mentioned PM2 command.

$ pm2 start --name <strong><app name></strong> npm -- start
Code language: HTML, XML (xml)

I have a dummy dashboard reactjs project and I want to run that as a service using PM2. So I run this command from root folder of my reactjs project —

$ pm2 start --name myreactapp npm -- start

Output:

You can see once I ran that command PM2 started a service with name “dashboard”. And status of the process is “online”, that means my application already running, I can quickly test that from browser using localhost:3000 URL.

To stop the service use command —

$ pm2 stop <app name>
Code language: HTML, XML (xml)

To delete the service use command —

$ pm2 delete <app name>
Code language: HTML, XML (xml)

Please note that, this is a quick & simple way, but not the best way to schedule a service with PM2, kindly visit PM2 official site for more information.

No Comments

Send Comment Edit Comment


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next