Skip to content

Commit 48d87ce

Browse files
jeniawhitenimrod-becker
authored andcommitted
Fixing supervisord
Fixing killing of processes
1 parent 01bb4b4 commit 48d87ce

File tree

7 files changed

+50
-14
lines changed

7 files changed

+50
-14
lines changed

src/deploy/NVA_build/deploy_base.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ function fix_security_issues {
351351

352352
function setup_supervisors {
353353
deploy_log "setup_supervisors start"
354-
355354
mkdir -p /tmp/supervisor
355+
mv /usr/bin/supervisord /usr/bin/supervisord_orig
356356
# Generate default supervisord config
357357
echo_supervisord_conf > /etc/supervisord.conf
358358
sed -i 's:logfile=.*:logfile=/tmp/supervisor/supervisord.log:' /etc/supervisord.conf
@@ -362,15 +362,17 @@ function setup_supervisors {
362362
# Autostart supervisor
363363
deploy_log "setup_supervisors autostart"
364364
cp -f ${CORE_DIR}/src/deploy/NVA_build/supervisord.orig /etc/rc.d/init.d/supervisord
365+
cp -f ${CORE_DIR}/src/deploy/NVA_build/supervisord.orig /usr/bin/supervisord
365366
chmod 777 /etc/rc.d/init.d/supervisord
367+
chmod 777 /usr/bin/supervisord
366368
chkconfig supervisord on
367369

368370
# Add NooBaa services configuration to supervisor
369371
deploy_log "setup_supervisors adding noobaa config to supervisord"
370372
echo "[include]" >> /etc/supervisord.conf
371373
echo "files = /etc/noobaa_supervisor.conf" >> /etc/supervisord.conf
372374
cp -f ${CORE_DIR}/src/deploy/NVA_build/noobaa_supervisor.conf /etc
373-
${SUPERD}
375+
${SUPERD} start
374376
${SUPERCTL} reread
375377
${SUPERCTL} update
376378

src/deploy/NVA_build/supervisord.orig

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,57 @@
44

55
. /etc/rc.d/init.d/functions
66

7-
SUPERVISORD="/usr/bin/supervisord"
7+
SUPERVISORD="/usr/bin/supervisord_orig"
88
PIDFILE="/tmp/supervisord.pid"
99

1010
start() {
1111
if [ ! -x "$SUPERVISORD" ]; then
1212
echo "$SUPERVISORD is not executable."
13+
logger -p local0.info "$SUPERVISORD is not executable."
1314
exit 1
1415
fi
15-
1616
echo "Starting ..."
17+
logger -p local0.info "Starting ..."
1718
ulimit -n 102400; $SUPERVISORD --pidfile $PIDFILE
1819

1920
return $?
2021
}
2122

2223
stop() {
2324
echo "Stopping ..."
25+
logger -p local0.info "Stopping ..."
26+
local supervisord_orig_pid=$(pgrep -lf $SUPERVISORD | awk '{print $1}')
27+
echo "supervisord_orig_pid=$supervisord_orig_pid"
28+
logger -p local0.info "supervisord_orig_pid=$supervisord_orig_pid"
29+
kill -9 ${supervisord_orig_pid}
30+
31+
local web_server_pid=$(pgrep -lf web_server.js | awk '{print $1}')
32+
echo "web_server_pid=$web_server_pid"
33+
logger -p local0.info "web_server_pid=$web_server_pid"
34+
kill -9 ${web_server_pid}
35+
36+
local bg_workers_pid=$(pgrep -lf bg_workers.js | awk '{print $1}')
37+
echo "bg_workers_pid=$bg_workers_pid"
38+
logger -p local0.info "bg_workers_pid=$bg_workers_pid"
39+
kill -9 ${bg_workers_pid}
40+
41+
local hosted_agents_starter_pid=$(pgrep -lf hosted_agents_starter.js | awk '{print $1}')
42+
echo "hosted_agents_starter_pid=$hosted_agents_starter_pid"
43+
logger -p local0.info "hosted_agents_starter_pid=$hosted_agents_starter_pid"
44+
kill -9 ${hosted_agents_starter_pid}
45+
46+
local s3rver_starter_pids=$(pgrep -lf s3rver_starter.js | awk '{print $1}')
47+
echo "s3rver_starter_pids=$s3rver_starter_pids"
48+
logger -p local0.info "s3rver_starter_pids=$s3rver_starter_pids"
49+
kill -9 ${s3rver_starter_pids}
50+
51+
local mongo_pids=$(pgrep -lf mongo | awk '{print $1}')
52+
echo "mongo_pids=$mongo_pids"
53+
logger -p local0.info "mongo_pids=$mongo_pids"
54+
kill -9 ${mongo_pids}
55+
2456
local p=$(cat $PIDFILE)
2557
kill -9 ${p}
26-
#unlink /tmp/supervisor.sock
27-
#local pid=$(lsof -i :8080|awk '{ print $2 }' | sed '1 d')
28-
#for p in ${pid} ; do
29-
#kill -9 ${p}
30-
#done
3158
[ $? -eq 0 ] && rm -f $PIDFILE
3259
return $retval
3360
}

src/deploy/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
/usr/bin/supervisord
2+
/usr/bin/supervisord start

src/test/scripts/reset_cluster.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ echo "removing $(hostname) from the cluster..."
88
cp -f /root/node_modules/noobaa-core/src/deploy/NVA_build/noobaa_supervisor.conf /etc/noobaa_supervisor.conf
99
sed -i "s:MONGO_RS_URL.*::" /root/node_modules/noobaa-core/.env
1010
supervisorctl shutdown
11-
supervisord
11+
supervisord start
1212
sleep 5
1313
/usr/bin/mongo nbcore --eval "db.dropDatabase()"
1414
/usr/bin/mongo local --eval "db.dropDatabase()"
1515
supervisorctl shutdown
16-
supervisord
16+
supervisord start

src/test/system_tests/test_md_aggregator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function init_system_to_ntp() {
132132
.finally(() => P.resolve()
133133
.then(() => {
134134
console.log('start supervisord');
135-
return promise_utils.exec('supervisord', {
135+
return promise_utils.exec('supervisord start', {
136136
ignore_rc: false,
137137
return_stdout: false
138138
});

src/upgrade/upgrade.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function mongo_upgrade() {
141141
dbg.log0('mongo_upgrade: Called');
142142
let secret;
143143
return disable_autostart()
144-
.then(() => promise_utils.exec(`${SUPERD}`, {
144+
.then(() => promise_utils.exec(`${SUPERD} start`, {
145145
ignore_rc: false,
146146
return_stdout: true,
147147
trim_stdout: true

src/upgrade/upgrade_wrapper.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,16 @@ function post_upgrade() {
157157
})
158158
)
159159
.then(() => exec(`echo "${agent_version_var}" >> ${CORE_DIR}/.env`))
160+
.then(() => fs_utils.file_must_not_exist('/usr/bin/supervisord_orig'))
161+
.then(
162+
() => exec(`mv /usr/bin/supervisord /usr/bin/supervisord_orig`),
163+
err => dbg.log0('supervisord_orig already exists, no changes required', err)
164+
)
160165
.then(() => exec(`cp -f ${CORE_DIR}/src/deploy/NVA_build/supervisord.orig /etc/rc.d/init.d/supervisord`))
166+
.then(() => exec(`cp -f ${CORE_DIR}/src/deploy/NVA_build/supervisord.orig /usr/bin/supervisord`))
161167
.then(() => dbg.log0('post_upgrade: Override supervisord'))
162168
.then(() => exec(`chmod 777 /etc/rc.d/init.d/supervisord`))
169+
.then(() => exec(`chmod 777 /usr/bin/supervisord`))
163170
.then(() => dbg.log0('post_upgrade: Configure permissions to supervisord'))
164171
.then(() => exec(`cp -f ${CORE_DIR}/src/deploy/NVA_build/first_install_diaglog.sh /etc/profile.d/`))
165172
.then(() => dbg.log0('post_upgrade: Copying first install dialog into profile.d'))

0 commit comments

Comments
 (0)