-
Notifications
You must be signed in to change notification settings - Fork 12
/
sensor_cloud
53 lines (47 loc) · 1.38 KB
/
sensor_cloud
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/sh
### BEGIN INIT INFO
# Provides: rails
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start a Rails instance
# Description: Do the simplest thing possible in keeping with
# upstart to spin up a single Rails instance.
### END INIT INFO
# Author: Sam Pointer
#
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
USER="quentin"
PORT=3000
RAILS_ROOT="/home/quentin/rails_projects/sensor_cloud"
COMMAND="rails s -e production -p $PORT -d"
DESCRIPTION="Rails instance"
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
su -c "cd $RAILS_ROOT && $COMMAND" - $USER
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESCRIPTION"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
esac