Forked from learncodeacademy/node-deploy-as-upstart-service.md
Last active
August 29, 2015 14:27
-
-
Save crystalclear/93c3d73a6193e1ea4b0b to your computer and use it in GitHub Desktop.
Revisions
-
learncodeacademy renamed this gist
Oct 17, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
learncodeacademy revised this gist
Oct 17, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,6 +31,7 @@ restart node-app #performs a stop and start. This is all we need for deployments ``` ###Step 2: give your `deploy` user permission to restart the node-app service without requiring a password You can make changes to this entry later by running `visudo` as root, but for now, just run this. ```bash echo "deploy ALL=(root) NOPASSWD: /sbin/restart node-app" >> /etc/sudoers ``` -
learncodeacademy revised this gist
Oct 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ exec /usr/local/bin/node bin/www ```bash start node-app stop node-app restart node-app #performs a stop and start. This is all we need for deployments ``` ###Step 2: give your `deploy` user permission to restart the node-app service without requiring a password -
learncodeacademy revised this gist
Oct 17, 2014 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy. To get around this, we're going to run our node app as an Upstart service. Upstart services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts. ###Step 1: Create a service for your node app - __ssh in as *root*__ `ssh root@youripaddress` @@ -17,30 +17,30 @@ nano /etc/init/node-app.conf start on filesystem and started networking respawn chdir /home/deploy/node-app env NODE_ENV=production #change this to staging if this is a staging server env PORT=3000 exec /usr/local/bin/node bin/www ``` - **Now your app will always start on reboot!** - You can also now you can start | stop | restart your app with these commands ```bash start node-app stop node-app restart node-app #performs a stop and start ``` ###Step 2: give your `deploy` user permission to restart the node-app service without requiring a password ```bash echo "deploy ALL=(root) NOPASSWD: /sbin/restart node-app" >> /etc/sudoers ``` ###Step 3: Adjust your flightplan.js file - remove the forever lines, replacing them with the last line here View full file, minus these changes [here](https://gist.github.com/learncodeacademy/35045e64d2bbe6eb14f9) ```javascript remote.log('Reload application'); remote.sudo('ln -snf ~/' + tmpDir + ' ~/'+appName, {user: username}); remote.exec('sudo restart node-app'); ```
-
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ Services are great, because, once started, the system auto-restarts them if they ###Step 1: Create a service for your node app - __ssh in as *root*__ `ssh root@youripaddress` - Create a node-app.conf file in /etc/init<br/> IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. `service node-app start` ```bash nano /etc/init/node-app.conf -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,10 +7,11 @@ Services are great, because, once started, the system auto-restarts them if they ###Step 1: Create a service for your node app - __ssh in as *root*__ `ssh root@youripaddress` - Create a node-app.conf file in /etc/init IMPORTANT: whatever filename you pick is what you will use to start|stop|restart your service i.e. `service node-app start` ```bash nano /etc/init/node-app.conf ``` - Give the file the following contents ```bash start on filesystem and started networking -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Services are great, because, once started, the system auto-restarts them if they ```bash nano /etc/init/node-app.conf ``` IMPORTANT: whatever filename you just picked is what you will use to start|stop|restart your service i.e. `service node-app start` - Give the file the following contents ```bash start on filesystem and started networking -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,7 @@ Services are great, because, once started, the system auto-restarts them if they - __ssh in as *root*__ `ssh root@youripaddress` - Create a node-app.conf file in /etc/init ```bash nano /etc/init/node-app.conf ``` - IMPORTANT: whatever filename you just picked is what you will use to start|stop|restart your service i.e. `service node-app start` - Give the file the following contents -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ Services are great, because, once started, the system auto-restarts them if they - Create a node-app.conf file in /etc/init ```bash cd /etc/init nano node-app.conf ``` - IMPORTANT: whatever filename you just picked is what you will use to start|stop|restart your service i.e. `service node-app start` - Give the file the following contents -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,12 +7,12 @@ Services are great, because, once started, the system auto-restarts them if they ###Step 1: Create a service for your node app - __ssh in as *root*__ `ssh root@youripaddress` - Create a node-app.conf file in /etc/init ```bash cd /etc/init vim node-app.conf ``` - IMPORTANT: whatever filename you just picked is what you will use to start|stop|restart your service i.e. `service node-app start` - Give the file the following contents ```bash start on filesystem and started networking respawn -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,8 @@ Services are great, because, once started, the system auto-restarts them if they ###Step 1: Create a service for your node app - __ssh in as *root*__ `ssh root@youripaddress` - Create a node-app.conf file in /etc/init - IMPORTANT: whatever filename you pick here is what you will use to start|stop|restart your service i.e. `service node-app start` ```bash cd /etc/init vim node-app.conf -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to re-deploy. To get around this, we're going to run our node app as a service. Services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts. -
learncodeacademy revised this gist
Oct 16, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running and you have to redeploy. To get around this, we're going to run our node app as a service. Services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts. -
learncodeacademy renamed this gist
Oct 16, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
learncodeacademy created this gist
Oct 16, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ Deploying a node app with Forever is great...until your server restarts unexpectedly. Then your app stops running. To get around this, we're going to run our node app as a service. Services are great, because, once started, the system auto-restarts them if they fail, or if the server restarts. ###Step 1: Create a service for your node app - __ssh in as *root*__ `ssh root@youripaddress` - Create a node-app.conf file in /etc/init - whatever name you pick here is what you will use to start|stop|restart your service ```bash cd /etc/init vim node-app.conf ``` - Give it the following contents ```bash start on filesystem and started networking respawn chdir /home/deploy/node-app env NODE_ENV=production env PORT=3000 exec /usr/local/bin/node bin/www ``` - **Now your app will always start on reboot!** - You can also now you can start | stop | restart your app with these commands ```bash service node-app start service node-app stop service node-app restart ``` ###Step 2: give your `deploy` user permission to run services without a password ```bash echo "deploy ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ``` ###Step 3: on Adjust your flightplan.js file View full file, minus these changes [here](https://gist.github.com/learncodeacademy/35045e64d2bbe6eb14f9) ```javascript remote.log('Reload application'); remote.sudo('ln -snf ~/' + tmpDir + ' ~/'+appName, {user: username}); remote.sudo('service node-app restart', {user: 'root'}); ```