Just change the conditional script to use systemctl try-restart and hopefully it will do what we want.
This commit is contained in:
Kevin Fenzi 2018-02-20 00:24:11 +00:00
parent 3896b82982
commit e621c76c8f
2 changed files with 10 additions and 21 deletions

View file

@ -15,20 +15,20 @@
action: service name=crond state=restarted action: service name=crond state=restarted
- name: restart fedmsg-gateway - name: restart fedmsg-gateway
command: /usr/local/bin/conditional-restart.sh fedmsg-gateway fedmsg-gateway command: /usr/local/bin/conditional-restart.sh fedmsg-gateway
- name: restart fedmsg-hub - name: restart fedmsg-hub
command: /usr/local/bin/conditional-restart.sh fedmsg-hub fedmsg-hub command: /usr/local/bin/conditional-restart.sh fedmsg-hub
# Note that, we're cool with arbitrary restarts on bodhi-backend02, just # Note that, we're cool with arbitrary restarts on bodhi-backend02, just
# not bodhi-backend01 or bodhi-backend03. 01 and 03 is where the releng/mash # not bodhi-backend01 or bodhi-backend03. 01 and 03 is where the releng/mash
# stuff happens and we # don't want to interrupt that. # stuff happens and we # don't want to interrupt that.
when: inventory_hostname not in ['bodhi-backend01.phx2.fedoraproject.org', 'bodhi-backend03.phx2.fedoraproject.org'] when: inventory_hostname not in ['bodhi-backend01.phx2.fedoraproject.org', 'bodhi-backend03.phx2.fedoraproject.org']
- name: restart fedmsg-irc - name: restart fedmsg-irc
command: /usr/local/bin/conditional-restart.sh fedmsg-irc fedmsg-irc command: /usr/local/bin/conditional-restart.sh fedmsg-irc
- name: restart fedmsg-relay - name: restart fedmsg-relay
command: /usr/local/bin/conditional-restart.sh fedmsg-relay fedmsg-relay command: /usr/local/bin/conditional-restart.sh fedmsg-relay
- name: restart koji-sync-listener - name: restart koji-sync-listener
action: service name=koji-sync-listener state=restarted action: service name=koji-sync-listener state=restarted

View file

@ -1,20 +1,9 @@
#!/bin/bash #!/bin/bash
# Restart SERVICE only if PACKAGE is installed. #
# We use this throughout handlers/restart_services.yml # We use this to try and restart a service.
# If it's not running, do nothing.
# If it is running, restart it.
#
SERVICE=$1 SERVICE=$1
PACKAGE=$2 /usr/bin/systemctl try-restart $1
rpm -q $PACKAGE
INSTALLED=$?
if [ $INSTALLED -eq 0 ]; then
echo "Package $PACKAGE installed. Attempting restart of $SERVICE."
/sbin/service $SERVICE restart
exit $? # Exit with the /sbin/service status code
fi
# If the package wasn't installed, then pretend everything is fine.
echo "Package $PACKAGE not installed. Skipping restart of $SERVICE."
exit 0