Setting up adonis server for deployment

I assume, you have a adonis server running on your server and listening to http://your-host:yourport Now we have to make this server listener to live long until we quit the console terminal. So lets make this adonis service as daemon, and it will run all the time then.

We use PM 2 for it.

PM2 is a Node Process Manager that will be used to keep our application alive forever.

*Step - 1: Installing PM2 *

npm install pm2 -g

Step - 2: Create a PM2 deamon and name it.

pm2 start /var/www/html/ --name my-app

Here first part is path to your server.js file and the last is the daemon name. It can be , its your choice.

After this command, a daemon "my-app will be listening to the port and host mentioned in server.js file.

*Step - 3: Aotomate the deployment *

# Content of your script /home/deploy/www/
cd /var/www/html/
git pull
npm i --production
node ace migration:run --force
pm2 restart my-app

Finally add execute permission -

chmod +x /home/deploy/www/

Yo are all set! Enjoy.

  • Roopz © 2020