foreman-tasks 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/bin/foreman-tasks +5 -0
- data/deploy/foreman-tasks.init +231 -0
- data/deploy/foreman-tasks.service +14 -0
- data/deploy/foreman-tasks.sysconfig +8 -0
- data/lib/foreman_tasks/version.rb +1 -1
- metadata +6 -2
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Put the following to your Foreman's bundle.d/Gemfile.local.rb:
|
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
gem 'dynflow', :git => 'https://github.com/Dynflow/dynflow.git'
|
14
|
-
gem 'foreman-tasks', :git => 'https://github.com/
|
14
|
+
gem 'foreman-tasks', :git => 'https://github.com/theforeman/foreman-tasks.git'
|
15
15
|
```
|
16
16
|
|
17
17
|
Run:
|
data/bin/foreman-tasks
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Init script for foreman-tasks
|
4
|
+
#
|
5
|
+
# chkconfig: - 88 12
|
6
|
+
# description: Init script for foreman-tasks
|
7
|
+
#
|
8
|
+
|
9
|
+
# Source function library.
|
10
|
+
. /etc/rc.d/init.d/functions
|
11
|
+
|
12
|
+
if [ -f /etc/sysconfig/foreman-tasks ]; then
|
13
|
+
. /etc/sysconfig/foreman-tasks
|
14
|
+
fi
|
15
|
+
|
16
|
+
prog=foreman-tasks
|
17
|
+
RETVAL=0
|
18
|
+
FOREMAN_USER=${FOREMAN_USER:-foreman}
|
19
|
+
FOREMAN_HOME=${FOREMAN_HOME:-/usr/share/foreman}
|
20
|
+
FOREMAN_DATA_DIR=${FOREMAN_DATA_DIR:-/var/lib/foreman}
|
21
|
+
FOREMAN_ENV=${FOREMAN_ENV:-production}
|
22
|
+
FOREMAN_TASK_PARAMS=${FOREMAN_TASK_PARAMS:--p foreman}
|
23
|
+
FOREMAN_PID_DIR=$FOREMAN_HOME/tmp/pids
|
24
|
+
FOREMAN_LOG_DIR=${FOREMAN_LOG_DIR:-/var/log/foreman}
|
25
|
+
TASK_SCRIPT="/usr/bin/foreman-tasks"
|
26
|
+
export RAILS_ENV=$FOREMAN_ENV
|
27
|
+
export FOREMAN_LOGGING=${FOREMAN_LOGGING:-warn}
|
28
|
+
export FOREMAN_LOGGING_SQL=${FOREMAN_LOGGING_SQL:-warn}
|
29
|
+
export RAILS_RELATIVE_URL_ROOT=$FOREMAN_PREFIX
|
30
|
+
export BUNDLER_EXT_GROUPS
|
31
|
+
export BUNDLER_EXT_NOSTRICT
|
32
|
+
export BUNDLER_EXT_HOME=$FOREMAN_HOME
|
33
|
+
|
34
|
+
print_higher() {
|
35
|
+
if [ 0$1 -gt 0$2 ]; then
|
36
|
+
echo $1
|
37
|
+
else
|
38
|
+
echo $2
|
39
|
+
fi
|
40
|
+
}
|
41
|
+
|
42
|
+
print_lower() {
|
43
|
+
if [ 0$1 -gt 0$2 ]; then
|
44
|
+
echo $2
|
45
|
+
else
|
46
|
+
echo $1
|
47
|
+
fi
|
48
|
+
}
|
49
|
+
|
50
|
+
status_of_one() {
|
51
|
+
PID_FILE="$1"
|
52
|
+
local RC
|
53
|
+
local RETVAL
|
54
|
+
if [ -f "$PID_FILE" ]; then
|
55
|
+
# set $pid
|
56
|
+
__pids_var_run NOT_USED $PID_FILE
|
57
|
+
RC=$?
|
58
|
+
if [ -n "$pid" -o 0$RC -gt 0 ]; then
|
59
|
+
RETVAL=2 # Program is dead and pid file exists
|
60
|
+
fi
|
61
|
+
#check if proces with pid from the file is running
|
62
|
+
if checkpid $pid; then
|
63
|
+
echo "running."
|
64
|
+
RETVAL=0
|
65
|
+
else
|
66
|
+
echo "not running."
|
67
|
+
RETVAL=1
|
68
|
+
fi
|
69
|
+
else
|
70
|
+
echo "not running."
|
71
|
+
RETVAL=3
|
72
|
+
fi
|
73
|
+
return $RETVAL
|
74
|
+
}
|
75
|
+
|
76
|
+
kstatus() {
|
77
|
+
RETVAL=0
|
78
|
+
SECONDVAL=256
|
79
|
+
echo -n "dynflow_executor is "
|
80
|
+
status_of_one $FOREMAN_PID_DIR/dynflow_executor.pid
|
81
|
+
RC=$?
|
82
|
+
RETVAL=$( print_higher $RC $RETVAL )
|
83
|
+
SECONDVAL=$( print_lower $RC $SECONDVAL )
|
84
|
+
echo -n "dynflow_executor_monitor is "
|
85
|
+
status_of_one $FOREMAN_PID_DIR/dynflow_executor_monitor.pid
|
86
|
+
RC=$?
|
87
|
+
RETVAL=$( print_higher $RC $RETVAL )
|
88
|
+
SECONDVAL=$( print_lower $RC $SECONDVAL )
|
89
|
+
if [ 0$SECONDVAL -eq 0 -a 0$RETVAL -gt 0 ]; then
|
90
|
+
# some is running, some not
|
91
|
+
return 10
|
92
|
+
else
|
93
|
+
return $RETVAL
|
94
|
+
fi
|
95
|
+
}
|
96
|
+
|
97
|
+
status_q() {
|
98
|
+
kstatus &> /dev/null
|
99
|
+
return $?
|
100
|
+
}
|
101
|
+
|
102
|
+
start() {
|
103
|
+
|
104
|
+
echo -n $"Starting $prog: "
|
105
|
+
status_q
|
106
|
+
STATUS=$?
|
107
|
+
if [ 0$STATUS -eq 0 ]; then
|
108
|
+
echo -n $"$prog is already running. "
|
109
|
+
RETVAL=0
|
110
|
+
echo_success
|
111
|
+
elif [ 0$STATUS -eq 10 ]; then
|
112
|
+
echo -n $"Some processes of $prog is already running. Some not. Please stop $prog first."
|
113
|
+
RETVAL=10
|
114
|
+
echo_failure
|
115
|
+
else
|
116
|
+
# rails expects you to run from the root of the app
|
117
|
+
pushd ${FOREMAN_HOME} >/dev/null
|
118
|
+
# start jobs
|
119
|
+
runuser -s /bin/bash - ${FOREMAN_USER} -c "\
|
120
|
+
BUNDLER_EXT_NOSTRICT='$BUNDLER_EXT_NOSTRICT' \
|
121
|
+
BUNDLER_EXT_HOME='$BUNDLER_EXT_HOME' \
|
122
|
+
RAILS_RELATIVE_URL_ROOT='$RAILS_RELATIVE_URL_ROOT' \
|
123
|
+
RAILS_ENV='$RAILS_ENV' \
|
124
|
+
FOREMAN_LOGGING='$FOREMAN_LOGGING' \
|
125
|
+
FOREMAN_LOGGING_SQL='$FOREMAN_LOGGING_SQL' \
|
126
|
+
$TASK_SCRIPT $FOREMAN_TASK_PARAMS -m -n $FOREMAN_TASK_WORKERS start &>>${FOREMAN_LOG_DIR}/jobs-startup.log"
|
127
|
+
RETVAL=$?
|
128
|
+
if [ $RETVAL = 0 ]; then
|
129
|
+
echo_success
|
130
|
+
else
|
131
|
+
echo_failure
|
132
|
+
fi
|
133
|
+
popd >/dev/null
|
134
|
+
fi
|
135
|
+
|
136
|
+
echo
|
137
|
+
return $RETVAL
|
138
|
+
}
|
139
|
+
|
140
|
+
stop() {
|
141
|
+
|
142
|
+
status_q
|
143
|
+
STATUS=$?
|
144
|
+
if [ 0$STATUS -eq 0 -o 0$STATUS -eq 10 ]; then
|
145
|
+
# rails expects you to run from the root of the app
|
146
|
+
pushd ${FOREMAN_HOME} >/dev/null
|
147
|
+
runuser -s /bin/bash - ${FOREMAN_USER} -c "\
|
148
|
+
BUNDLER_EXT_NOSTRICT='$BUNDLER_EXT_NOSTRICT' \
|
149
|
+
BUNDLER_EXT_HOME='$BUNDLER_EXT_HOME' \
|
150
|
+
RAILS_RELATIVE_URL_ROOT='$RAILS_RELATIVE_URL_ROOT' \
|
151
|
+
RAILS_ENV='$RAILS_ENV' \
|
152
|
+
FOREMAN_LOGGING='$FOREMAN_LOGGING' \
|
153
|
+
FOREMAN_LOGGING_SQL='$FOREMAN_LOGGING_SQL' \
|
154
|
+
$TASK_SCRIPT $FOREMAN_TASK_PARAMS -m -n $FOREMAN_TASK_WORKERS stop &>>${FOREMAN_LOG_DIR}/jobs-startup.log"
|
155
|
+
if [ -f $FOREMAN_PID_DIR/dynflow_executor_monitor.pid ]; then
|
156
|
+
echo -n $"Stopping dynflow_executor_monitor: "
|
157
|
+
killproc -p $FOREMAN_PID_DIR/dynflow_executor_monitor.pid
|
158
|
+
echo
|
159
|
+
fi
|
160
|
+
if [ -f $FOREMAN_PID_DIR/dynflow_executor.pid ]; then
|
161
|
+
echo -n $"Stopping dynflow_executor: "
|
162
|
+
killproc -p $FOREMAN_PID_DIR/dynflow_executor.pid
|
163
|
+
echo
|
164
|
+
fi
|
165
|
+
popd >/dev/null
|
166
|
+
RETVAL=0
|
167
|
+
else
|
168
|
+
RETVAL=0
|
169
|
+
echo -n "Stopping $prog: "
|
170
|
+
echo_failure
|
171
|
+
echo
|
172
|
+
fi
|
173
|
+
|
174
|
+
return $RETVAL
|
175
|
+
}
|
176
|
+
|
177
|
+
restart() {
|
178
|
+
stop
|
179
|
+
start
|
180
|
+
}
|
181
|
+
|
182
|
+
condstop() {
|
183
|
+
status_q
|
184
|
+
STATUS=$?
|
185
|
+
if [ 0$STATUS -eq 0 -o 0$STATUS -eq 10 ]; then
|
186
|
+
stop
|
187
|
+
else
|
188
|
+
RETVAL=0
|
189
|
+
fi
|
190
|
+
}
|
191
|
+
|
192
|
+
condrestart() {
|
193
|
+
status_q
|
194
|
+
STATUS=$?
|
195
|
+
if [ 0$STATUS -eq 0 -o 0$STATUS -eq 10 ]; then
|
196
|
+
restart
|
197
|
+
else
|
198
|
+
RETVAL=0
|
199
|
+
fi
|
200
|
+
}
|
201
|
+
|
202
|
+
case "$1" in
|
203
|
+
start)
|
204
|
+
start
|
205
|
+
;;
|
206
|
+
stop)
|
207
|
+
stop
|
208
|
+
;;
|
209
|
+
restart)
|
210
|
+
restart
|
211
|
+
;;
|
212
|
+
condrestart|try-restart)
|
213
|
+
condrestart
|
214
|
+
;;
|
215
|
+
condstop)
|
216
|
+
condstop
|
217
|
+
;;
|
218
|
+
status)
|
219
|
+
kstatus
|
220
|
+
RETVAL=$?
|
221
|
+
;;
|
222
|
+
*)
|
223
|
+
echo "Usage: {start|stop|restart|condrestart|condstop|status}"
|
224
|
+
exit 1
|
225
|
+
;;
|
226
|
+
esac
|
227
|
+
|
228
|
+
exit $RETVAL
|
229
|
+
|
230
|
+
# vim:set sw=4 ts=4 et:
|
231
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Foreman jobs daemon
|
3
|
+
Documentation=https://github.com/iNecas/foreman-tasks
|
4
|
+
After=network.target remote-fs.target nss-lookup.target
|
5
|
+
|
6
|
+
[Service]
|
7
|
+
Type=forking
|
8
|
+
WorkingDirectory=/usr/share/foreman
|
9
|
+
ExecStart=/usr/bin/foreman-tasks start
|
10
|
+
ExecStop=/usr/bin/foreman-tasks stop
|
11
|
+
EnvironmentFile=-/etc/sysconfig/foreman-tasks
|
12
|
+
|
13
|
+
[Install]
|
14
|
+
WantedBy=multi-user.target
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -150,10 +150,14 @@ files:
|
|
150
150
|
- app/models/foreman_tasks/lock.rb
|
151
151
|
- app/models/foreman_tasks/task.rb
|
152
152
|
- bin/dynflow-executor
|
153
|
+
- bin/foreman-tasks
|
153
154
|
- config/routes.rb
|
154
155
|
- db/migrate/20131209122644_create_foreman_tasks_locks.rb
|
155
156
|
- db/migrate/20131205204140_create_foreman_tasks.rb
|
156
157
|
- db/migrate/20140324104010_remove_foreman_tasks_progress.rb
|
158
|
+
- deploy/foreman-tasks.init
|
159
|
+
- deploy/foreman-tasks.service
|
160
|
+
- deploy/foreman-tasks.sysconfig
|
157
161
|
- lib/tasks/gettext.rake
|
158
162
|
- lib/foreman_tasks/tasks/dynflow.rake
|
159
163
|
- lib/foreman_tasks/engine.rb
|