Skip to content

Start Production

Video Lecture

Start Production Start Production

 (Pay Per View)

You can use PayPal to purchase a one time viewing of this video for $1.49 USD.

Pay Per View Terms

  • One viewing session of this video will cost the equivalent of $1.49 USD in your currency.
  • After successful purchase, the video will automatically start playing.
  • You can pause, replay and go fullscreen as many times as needed in one single session for up to an hour.
  • Do not refresh the browser since it will invalidate the session.
  • If you want longer-term access to all videos, consider purchasing full access through Udemy or YouTube Memberships instead.
  • This Pay Per View option does not permit downloading this video for later viewing or sharing.
  • All videos are Copyright © 2019-2025 Sean Bradley, all rights reserved.

Description

Navigate into the folder on your new server that contains the package.json

cd /var/www/socketio-example

Now, install the dependencies from the package.json by using the command,

npm install --omit=dev

Now, you can start the server script.

npm start

Open a browser and visit http://[your ip address]:3000

Go back into SSH and press Ctrl-C to stop the server.

We will now start it using the PM2 process manager for Node.JS.

It will start our script as a background process so that it doesn't block the terminal, and it remains running if we close Putty or exit the SSH session.

PM2 will also try to restart our application in case it ever crashes.

Install PM2 globally.

npm install pm2 -g

CD into the folder where the package.json was saved.

cd /var/www/socketio-example

Now we can start our server using PM2.

pm2 start npm -- start

To check the status,

pm2 status

To check the server output,

pm2 logs

To stop a PM2 process,

pm2 stop 0

To start a PM2 process,

pm2 start 0

To rename a PM2 process,

pm2 restart 0 ---name socketio-example