0

I have a simple express.js-powered API running on an ubuntu server with pm2. The server.js and the other files are in /var/www/node/api/.

On this server, at /srv/git-repos/api.git/ is my git repository, where I commit new changes from my local machine.

The Question is, is it possible, that every time I commit new changes to the server, it recognizes this, and clones my repository to let's say /var/www/node/api-dev/(which will then be available at dev.example.com, this could be made possible with nginx, so there is no problem) and restarts my pm2 instance with pm2 restart api.

Because then I would test, if my changes work on the server, and when they do, I just can copy the content of /var/www/node/api-dev to /var/www/node/api manually.

Or is there another, better workflow? It's just a small API on which I will make many changes because I want to develop it for the needs of my frontend.

Thanks for your answers and suggestions, I hope it's understandable what I want to archive.

Fabian
  • 67
  • 7

1 Answers1

0
git commit
git clone <repo> ../api-dev
pm2 restart api

Save it as c.sh and run with ./c.sh or add to your .bashrc

Smart Manoj
  • 3,837
  • 2
  • 24
  • 45
  • Thanks for your answer, this is what I do currently. Isn't there an option to automate this process? – Fabian Apr 28 '19 at 16:40