~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/pyscrabble-server

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides:          pyscrabble-server
 
4
# Required-Start:    $local_fs $remote_fs
 
5
# Required-Stop:     $local_fs $remote_fs
 
6
# Default-Start:     2 3 4 5
 
7
# Default-Stop:      0 1 6
 
8
# Short-Description: PyScrabble server
 
9
# Description:       Controls the PyScrabble server
 
10
### END INIT INFO
 
11
 
 
12
set -e
 
13
 
 
14
PATH=/sbin:/bin:/usr/bin
 
15
DESC="PyScrabble server"
 
16
NAME=python
 
17
NAME2=pyscrabble-server
 
18
DAEMON=/usr/sbin/pyscrabble-server
 
19
PIDFILE=/var/run/$NAME2.pid
 
20
SCRIPTNAME=/etc/init.d/$NAME2
 
21
 
 
22
# Gracefully exit if the package has been removed.
 
23
test -x $DAEMON || exit 0
 
24
 
 
25
. /lib/lsb/init-functions
 
26
 
 
27
USER="pyscrabble"
 
28
 
 
29
# Read config file if it is present.
 
30
if [ -r /etc/default/$NAME2 ]; then
 
31
        . /etc/default/$NAME2
 
32
fi
 
33
 
 
34
d_running() {
 
35
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
 
36
                --name $NAME --test > /dev/null
 
37
}
 
38
 
 
39
#
 
40
#       Function that starts the daemon/service.
 
41
#
 
42
d_start() {
 
43
        start-stop-daemon --start --oknodo --quiet --pidfile $PIDFILE --name $NAME \
 
44
            --background --make-pidfile --chuid "$USER" --startas $DAEMON
 
45
}
 
46
 
 
47
#
 
48
#       Function that stops the daemon/service.
 
49
#
 
50
d_stop() {
 
51
        start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE --name $NAME
 
52
        rm -f $PIDFILE
 
53
}
 
54
 
 
55
case "$1" in
 
56
  start)
 
57
        log_daemon_msg "Starting $DESC" "$NAME2"
 
58
        if d_running; then 
 
59
            log_progress_msg "already running"
 
60
        else 
 
61
            d_start;
 
62
        fi
 
63
        log_end_msg 0
 
64
        ;;
 
65
  stop)
 
66
        log_daemon_msg "Stopping $DESC" "$NAME2"
 
67
        if ! d_running; then
 
68
            log_progress_msg "not running"
 
69
        else
 
70
            d_stop
 
71
        fi
 
72
        log_end_msg 0
 
73
        ;;
 
74
  #reload)
 
75
        #
 
76
        #       If the daemon can reload its configuration without
 
77
        #       restarting (for example, when it is sent a SIGHUP),
 
78
        #       then implement that here.
 
79
        #
 
80
        #       If the daemon responds to changes in its config file
 
81
        #       directly anyway, make this an "exit 0".
 
82
        #
 
83
        # echo -n "Reloading $DESC configuration..."
 
84
        # d_reload
 
85
        # echo "done."
 
86
  #;;
 
87
  restart|force-reload)
 
88
        #
 
89
        #       If the "reload" option is implemented, move the "force-reload"
 
90
        #       option to the "reload" entry above. If not, "force-reload" is
 
91
        #       just the same as "restart".
 
92
        #
 
93
        log_daemon_msg "Restarting $DESC" "$NAME2"
 
94
        d_stop
 
95
        # One second might not be time enough for a daemon to stop, 
 
96
        # if this happens, d_start will fail (and dpkg will break if 
 
97
        # the package is being upgraded). Change the timeout if needed
 
98
        # be, or change d_stop to have start-stop-daemon use --retry. 
 
99
        # Notice that using --retry slows down the shutdown process somewhat.
 
100
        sleep 1
 
101
        d_start
 
102
        log_end_msg 0
 
103
        ;;
 
104
  status)
 
105
        d_running || status="not "
 
106
        log_action_msg "Status of $DESC:" "${status}running"
 
107
        ;;
 
108
  *)
 
109
        # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
 
110
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
 
111
        exit 1
 
112
        ;;
 
113
esac
 
114
 
 
115
exit 0