Advertisement
Guest User

pulp-service.sh

a guest
May 5th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.86 KB | None | 0 0
  1. #!/bin/bash
  2. # Manage pulp-related services en-masse
  3.  
  4. function ensure_services_running {
  5.   for s in mongod.service qpidd.service pulp_celerybeat.service pulp_resource_manager.service pulp_workers.service httpd.service; do
  6.     ISACTIVE="99"
  7.     COUNTER="0"
  8.     while [ "$ISACTIVE" != 0 ]; do
  9.       systemctl is-active "$s" > /dev/null
  10.       ISACTIVE="$?"
  11.       if [ "$ISACTIVE" != 0 ]; then
  12.         systemctl start $s 2>&1
  13.         sleep 3
  14.         COUNTER=$((COUNTER+1))
  15.       fi
  16.       if [ $COUNTER -gt 10 ]; then
  17.         exit 0
  18.       fi
  19.     done
  20.   done
  21. }
  22.  
  23.  
  24. case $1 in
  25.   status)
  26.      systemctl -n 0 status mongod qpidd httpd pulp_celerybeat pulp_resource_manager pulp_workers
  27.   ;;
  28.   full-status)
  29.     systemctl status mongod qpidd httpd pulp_celerybeat pulp_resource_manager pulp_workers
  30.   ;;
  31.   start)
  32.     ensure_services_running
  33.   ;;
  34.   stop)
  35.     systemctl stop pulp_resource_manager pulp_celerybeat pulp_workers httpd qpidd mongod
  36.   ;;
  37.   restart)
  38.     services="qpidd httpd pulp_celerybeat pulp_resource_manager pulp_workers"
  39.     systemctl restart $services
  40.     for s in $services; do
  41.       echo "Service $s is $(systemctl is-active $s)"
  42.     done
  43.   ;;
  44.   full-restart)
  45.     services="mongod qpidd httpd pulp_celerybeat pulp_resource_manager pulp_workers"
  46.     systemctl restart $services
  47.     for s in $services; do
  48.       echo "Service $s is $(systemctl is-active $s)"
  49.     done
  50.   ;;
  51.   *)
  52.     cat << EOF
  53.     This script isn't smart enough for that option; avail options are:
  54.  
  55.       status - show short status of all Pulp services
  56.  
  57.       full-status - status + journalctl messages
  58.  
  59.       start - start up Pulp services in sane order
  60.  
  61.       stop - shut down Pulp services in sane order
  62.  
  63.       restart - restart all Pulp services in sane order, except Mongo
  64.  
  65.       full-restart - even restart mongo; you probably don't want to do this
  66.  
  67. EOF
  68. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement