There are so many different ways to deploy a node app around the internet. Here’s my way. A way I no longer use.
Use git for version control
sudo npm install -g forever
Allow the git user account (which should be unprivileged) to host on port 80. After following this guide I decided to use setcap:
sudo apt-get install libcap2-bin sudo setcap 'cap_net_bind_service=%2Bep' /usr/local/bin/node
Add a post-receive hook on the remote (bare) repository to check out and restart the node process using forever. For example:
#!/bin/bash export GIT_WORK_TREE=/home/naggie/dspa/ git checkout -f cd $GIT_WORK_TREE forever stop dspa-server.js forever start dspa-server.js
That’s it! Simply push to the server to update and restart the node instance.
Also a convention is to use an environment variable to define the port. This is most useful when a proxy is used (for example, to use apache). This is used, for example, to work with the cloud9 ide. Nowadays I recommend installing a systemd service. ↩︎
Nowadays I recommend installing a systemd service. ↩︎