Created
June 28, 2015 08:22
-
-
Save checkaayush/0b370f3ab38f2e403a63 to your computer and use it in GitHub Desktop.
Create your own service using Upstart.
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 characters
#!upstart | |
description "ESS Server" | |
author "Aayush Sarva, <[email protected]>" | |
env DIRECTORY=/home/dev/electoralsearch_server/ | |
# Specify Runlevel events (Refer [1]) | |
# When to start the service | |
start on runlevel [2345] | |
# When to stop the service | |
stop on runlevel [06] | |
# Process | |
script | |
export HOME="/root" | |
cd $DIRECTORY | |
# Run Server | |
exec sudo /usr/bin/node /home/dev/electoralsearch_server/server-side.js | |
end script | |
## sudo initctl reload-configuration | |
## sudo initctl list | grep testservice | |
## sudo start testservice | |
## sudo stop testservice | |
## Developer Notes: | |
# [1] Background on Runlevels: | |
# Runlevels define modes of system operation. | |
# Runlevels 0, 1 and 6 are reserved. Runlevel 0 is used to halt the | |
# system and 6 to reboot the system. Runlevel 1 is used to bring the | |
# system back down into single-user mode, after which the runlevel will be S. | |
# [2] When you initially copy a new conf file into the /etc/init folder you need to call : initctl reload-configuration | |
# By this your upstart should be properly registered. | |
# References: | |
# A) http://upstart.ubuntu.com/cookbook | |
# B) https://help.ubuntu.com/community/UbuntuBootupHowto | |
# C) http://upstart.ubuntu.com/getting-started.html | |
#First, you can check that your job is actually known to upstart: | |
#sudo initctl list | grep your_job_name | |
#If it's not found, you can try reloading the configuration and then re-checking: | |
#sudo initctl reload-configuration | |
#sudo start your_job_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment