-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpassenger-app
More file actions
executable file
·113 lines (94 loc) · 2.24 KB
/
Copy pathpassenger-app
File metadata and controls
executable file
·113 lines (94 loc) · 2.24 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
warn () { echo -e "$1" >&2; }
usage() {
cat <<EOD
Usage: passenger-app <app> <command> [<args>]
Commands:
start Start application <app>
reload Reload application <app>
stop Stop application <app>
restart Restart application <app>
status Run passenger-status with <args>
config Run passenger-config with <args>
EOD
}
config() {
exec rbfu passenger-config "$@"
}
status() {
exec rbfu passenger-status "$@"
}
start() {
cd "$APPDIR"
exec rbfu passenger start current --daemonize --instance-registry-dir ${PASSENGER_INSTANCE_REGISTRY_DIR} --engine builtin --socket ${PASSENGER_INSTANCE_REGISTRY_DIR}/app.sock --pid-file ${PASSENGER_INSTANCE_REGISTRY_DIR}/app.pid --log-file ${APPDIR}/shared/log/passenger.log --environment production
}
reload() {
exec /usr/bin/touch ${APPDIR}/shared/tmp/restart.txt
}
stop() {
exec rbfu passenger stop --pid-file ${PASSENGER_INSTANCE_REGISTRY_DIR}/app.pid
}
restart() {
echo "Shutting down application ..."
rbfu passenger stop --pid-file ${PASSENGER_INSTANCE_REGISTRY_DIR}/app.pid
sleep 5
start
}
APP=$1; shift
ACTION=$1; shift
# sanity checks
[ ! "$APP" ] && warn "Please specify the application to use" && exit 1
if [ "$APP" == "--help" ]; then
usage && exit 0
fi
if [ ! -n "$PASSENGER_APPS_ROOT" ]; then
PASSENGER_APPS_ROOT="/srv/apps"
fi
if [ ! -d "$PASSENGER_APPS_ROOT" ]; then
warn "Passenger applications root not found at $PASSENGER_APPS_ROOT"
warn "Check the PASSENGER_APPS_ROOT environment variable"
exit 1
fi
APPDIR="$PASSENGER_APPS_ROOT/$APP"
if [ ! -d "$APPDIR" ]; then
warn "Application $APP not found at $APPDIR"
exit 1
fi
PASSENGER_INSTANCE_REGISTRY_DIR="$APPDIR/passenger"
if [ ! -d "$PASSENGER_INSTANCE_REGISTRY_DIR" ]; then
warn "Passenger instance registry not found at $PASSENGER_INSTANCE_REGISTRY_DIR"
exit 1
fi
# TODO: check env variables
export PATH
export GEM_HOME
export GEM_PATH
export PASSENGER_ROOT
export PASSENGER_INSTANCE_REGISTRY_DIR
export RUBY_VERSION_DIR="$APPDIR/current"
case "$ACTION" in
help)
usage && exit 0
;;
start)
start
;;
reload)
reload
;;
stop)
stop
;;
restart)
restart
;;
status)
status $@
;;
config)
config $@
;;
*)
usage && exit 1
;;
esac