Mercurial > kallithea
annotate init.d/kallithea-daemon-debian @ 6554:2c3d30095d5e
gearbox: replace paster with something TurboGears2-ish that still works with the Pylons stack
This is a step towards moving away from the Pylons stack to TurboGears2, but
still independent of it.
Some notes from the porting - it could perhaps be the missing(?) documentation
for migrating from paster to gearbox:
Note: 'gearbox' without parameters will crash - specify '-h' to get started
testing.
Replace paster
summary = 'yada yada'
with the first line of the docstring of the Command class ... or override
get_description.
Note: All newlines in the docstring will be collapsed and mangle the long help
text.
Grouping of commands is not possible. Standard commands (for development) can't
be customized under the same name or hidden. (Like for paster, the conceptual
model also assumes that the sub-command naming is namespaced so commands from
other packages won't conflict.)
The usage help is fully automated from the declared options.
For all deprecated Commands, replace paster
hidden = True
with gearbox
deprecated = True
Note: config_file, takes_config_file, min_args and max_args are not available /
relevant.
The gearbox parser is customized by overriding get_parser - there is nothing
like paster update_parser.
Gearbox is using argparse instead of optparse ... but argparse add_argument is
mostly backwards compatible with optparse add_option.
Instead of overriding command or run as in paster, override take_action in
gearbox. The parsed arguments are passed to take_action, not available on the
command instance.
Paster BadCommand is not available and must be handled manually, terminating
with sys.exit(1).
There is no standard make-config command in gearbox.
Paster appinstall has been replaced by the somewhat different setup_app module
in gearbox. There is still no clean way to pass parameters to SetupAppCommand
and it relies on websetup and other apparently unnecessary complexity. Instead,
implement setup-db from scratch.
Minor change by Thomas De Schampheleire: add gearbox logging configuration.
Because we use logging.config.fileConfig(.inifile) during gearbox command
execution, the logging settings need to be correct and contain a block for
gearbox logging itself. Otherwise, errors in command processing are not even
visible and the command exits silently.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 25 Oct 2016 21:32:24 +0200 |
parents | e285bb7abb28 |
children | 71bdbf129190 |
rev | line source |
---|---|
12 | 1 #!/bin/sh -e |
426
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
2 ######################################## |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
3 #### THIS IS A DEBIAN INIT.D SCRIPT #### |
426
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
4 ######################################## |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
5 |
12 | 6 ### BEGIN INIT INFO |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
7 # Provides: kallithea |
12 | 8 # Required-Start: $all |
9 # Required-Stop: $all | |
10 # Default-Start: 2 3 4 5 | |
11 # Default-Stop: 0 1 6 | |
4190
99ad9d0af1a3
Rename init scripts and fix references inside them
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3225
diff
changeset
|
12 # Short-Description: starts instance of kallithea |
99ad9d0af1a3
Rename init scripts and fix references inside them
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3225
diff
changeset
|
13 # Description: starts instance of kallithea using start-stop-daemon |
12 | 14 ### END INIT INFO |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
15 |
4190
99ad9d0af1a3
Rename init scripts and fix references inside them
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3225
diff
changeset
|
16 APP_NAME="kallithea" |
3225
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
17 APP_HOMEDIR="opt" |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
18 APP_PATH="/$APP_HOMEDIR/$APP_NAME" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
19 |
426
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
20 CONF_NAME="production.ini" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
21 |
426
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
22 PID_PATH="$APP_PATH/$APP_NAME.pid" |
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
23 LOG_PATH="$APP_PATH/$APP_NAME.log" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
24 |
3225
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
25 PYTHON_PATH="/$APP_HOMEDIR/$APP_NAME-venv" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
26 |
3225
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
27 RUN_AS="root" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
28 |
6554
2c3d30095d5e
gearbox: replace paster with something TurboGears2-ish that still works with the Pylons stack
Mads Kiilerich <madski@unity3d.com>
parents:
6370
diff
changeset
|
29 DAEMON="$PYTHON_PATH/bin/gearbox" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
30 |
426
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
31 DAEMON_OPTS="serve --daemon \ |
3225
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
32 --user=$RUN_AS \ |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
33 --group=$RUN_AS \ |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
34 --pid-file=$PID_PATH \ |
6554
2c3d30095d5e
gearbox: replace paster with something TurboGears2-ish that still works with the Pylons stack
Mads Kiilerich <madski@unity3d.com>
parents:
6370
diff
changeset
|
35 --log-file=$LOG_PATH -c $APP_PATH/$CONF_NAME" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
36 |
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
37 |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
38 start() { |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
39 echo "Starting $APP_NAME" |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
40 PYTHON_EGG_CACHE="/tmp" start-stop-daemon -d $APP_PATH \ |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
41 --start --quiet \ |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
42 --pidfile $PID_PATH \ |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
43 --user $RUN_AS \ |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
44 --exec $DAEMON -- $DAEMON_OPTS |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
45 } |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
46 |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
47 stop() { |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
48 echo "Stopping $APP_NAME" |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
49 start-stop-daemon -d $APP_PATH \ |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
50 --stop --quiet \ |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
51 --pidfile $PID_PATH || echo "$APP_NAME - Not running!" |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
52 |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
53 if [ -f $PID_PATH ]; then |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
54 rm $PID_PATH |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
55 fi |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
56 } |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
57 |
3225
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
58 status() { |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
59 echo -n "Checking status of $APP_NAME ... " |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
60 pid=`cat $PID_PATH` |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
61 status=`ps ax | grep $pid | grep -ve grep` |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
62 if [ "$?" -eq 0 ]; then |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
63 echo "running" |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
64 else |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
65 echo "NOT running" |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
66 fi |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
67 } |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
68 |
12 | 69 case "$1" in |
3225
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
70 status) |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
71 status |
f9540f9c5999
little improvements for debian init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
1262
diff
changeset
|
72 ;; |
12 | 73 start) |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
74 start |
12 | 75 ;; |
76 stop) | |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
77 stop |
12 | 78 ;; |
79 restart) | |
426
17d5028e055c
updated init scripts to start-stop-daemons
Marcin Kuzminski <marcin@python-works.com>
parents:
38
diff
changeset
|
80 echo "Restarting $APP_NAME" |
432
90512560ed4d
more with init scripts !
Marcin Kuzminski <marcin@python-works.com>
parents:
431
diff
changeset
|
81 ### stop ### |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
82 stop |
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
83 wait |
432
90512560ed4d
more with init scripts !
Marcin Kuzminski <marcin@python-works.com>
parents:
431
diff
changeset
|
84 ### start ### |
1262
238bea955b54
simplified example init.d script
Marcin Kuzminski <marcin@python-works.com>
parents:
552
diff
changeset
|
85 start |
433
aeafda5481e4
more on that neverending topic :) init scripts
Marcin Kuzminski <marcin@python-works.com>
parents:
432
diff
changeset
|
86 ;; |
12 | 87 *) |
88 echo "Usage: $0 {start|stop|restart}" | |
89 exit 1 | |
6370
e285bb7abb28
scripts: apply whitespace cleanup to more files - opt out instead of opt in
Mads Kiilerich <mads@kiilerich.com>
parents:
4190
diff
changeset
|
90 esac |