Run Remote Code on Server with pm2

Run Remote Code on Server with pm2 - Simple

There are Broadly two types of code:-

1. CRON based (a code which run itself after sometime continuously)

2. Server based

Now,
 

 

# Deploying Backend Code

Steps:

1. Clone the Repository using https.

2. Checkout to your preferable branch.

3. Install all dependencies using npm i

4. Configure pm2 and start the server. 

that's all!


Process:

1. git clone "https://......"

2. git checkout "branchName"

3. npm i

4. pm2 start "Entry point file path" --name "server name"
    For example if your entry point file is app.js then the above command will look like - pm2 start app.js --name backend


Tips 

* Use command pm2 list to track your recently started server and it's pm2 ID.

* Use command pm2 logs "pm2 ID" to check the logs for any error/s.

 

# Deploying Frontend Code

Steps:

1. Clone the repository using https.

2. Checkout to your preferable branch

3. Install all dependencies using npm i

4. Run the build version of the code.

That's all! Yes,  No pm2 for frontend

 

Process:

1. git clone "https://......"

2. git checkout "branchName"

3. npm i

4. npm run build

 


Comments

Popular posts from this blog

Mastering Retention - The power of Spaced repetition and Deliberate Practice

Free & Easy Designing tools for a Software Developer

My Advice to my Juniors, My Biggest College mistakes - Raw