From 4ca406b89f5b539633355ce90eb2700461fdd24b Mon Sep 17 00:00:00 2001 From: bohung Date: Sat, 23 Jul 2022 12:22:13 +0800 Subject: [PATCH] Update orbit service. --- orbit_service.sh | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/orbit_service.sh b/orbit_service.sh index b94245a..0db5adf 100644 --- a/orbit_service.sh +++ b/orbit_service.sh @@ -49,16 +49,44 @@ start_orbit () { echo "Starting $ORBIT_ROOT"; sudo su -l $ORBIT_USER -c "cd $ORBIT_ROOT && bundle exec unicorn_rails -D -E $RAILS_ENV -c config/unicorn.rb"; } - +bundle_orbit () { + args="$1" + if [[ -z $args ]]; then + args="install" + fi + sudo su -l $ORBIT_USER -c "cd $ORBIT_ROOT && bundle $args"; +} case $1 in +install) + if [ ! -z "$2" ]; then + get_orbit_root $2 + bundle_orbit + else + closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)" + for APP in `ls -1 $NGINX_ORBIT_SITES`; do + get_orbit_root $APP; + if [[ ! "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + bundle_orbit; + fi + done + fi + + exit 0; +;; start) if [ ! -z "$2" ]; then get_orbit_root $2 start_orbit else + closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)" for APP in `ls -1 $NGINX_ORBIT_SITES`; do get_orbit_root $APP; - start_orbit; + if [[ "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + echo "Stopping $ORBIT_ROOT"; + sig QUIT && continue; + else + start_orbit; + fi done fi @@ -123,11 +151,17 @@ restart|reload) echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead" start_orbit else + closed_sites="$(cat /home/$ORBIT_USER/closed_sites.txt)" for APP in `ls -1 $NGINX_ORBIT_SITES`; do get_orbit_root $APP; - sig USR2 && echo "$ORBIT_ROOT reloaded OK" && continue; - echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead"; - start_orbit; + if [[ "$closed_sites" =~ "$ORBIT_ROOT" ]]; then + echo "Stopping $ORBIT_ROOT"; + sig QUIT && continue; + else + sig USR2 && echo "$ORBIT_ROOT reloaded OK" && continue; + echo >&2 "Couldn't reload $ORBIT_ROOT, starting instead"; + start_orbit; + fi done fi exit 0;