diff --git a/ct/sure.sh b/ct/sure.sh index b095aaaae..a841a4674 100644 --- a/ct/sure.sh +++ b/ct/sure.sh @@ -30,9 +30,38 @@ function update_script() { fi if check_for_gh_release "Sure" "we-promise/sure"; then - msg_info "Stopping Service" - $STD systemctl stop sure - msg_ok "Stopped Service" + if [[ ! -f /etc/systemd/system/sure-worker.service ]]; then + cat </etc/systemd/system/sure-worker.service +[Unit] +Description=Sure Background Worker (Sidekiq) +After=network.target redis-server.service + +[Service] +Type=simple +WorkingDirectory=/opt/sure +Environment=RAILS_ENV=production +Environment=BUNDLE_DEPLOYMENT=1 +Environment=BUNDLE_WITHOUT=development +Environment=PATH=/root/.rbenv/shims:/root/.rbenv/bin:/usr/bin:/usr/local/bin:/sbin:/bin +EnvironmentFile=/etc/sure/.env +ExecStart=/opt/sure/bin/bundle exec sidekiq -e production +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +EOF + systemctl enable -q sure-worker + msg_info "Stopping Service" + $STD systemctl stop sure + msg_ok "Stopped Service" + else + msg_info "Stopping services" + $STD systemctl stop sure-worker sure + msg_ok "Stopped services" + fi CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Sure" "we-promise/sure" "tarball" "latest" "/opt/sure" RUBY_VERSION="$(cat /opt/sure/.ruby-version)" RUBY_INSTALL_RAILS=false setup_ruby @@ -50,9 +79,9 @@ function update_script() { unset SECRET_KEY_BASE_DUMMY msg_ok "Updated Sure" - msg_info "Starting Service" - $STD systemctl start sure - msg_ok "Started Service" + msg_info "Starting Services" + $STD systemctl start sure sure-worker + msg_ok "Started Services" msg_ok "Updated successfully!" fi exit diff --git a/install/sure-install.sh b/install/sure-install.sh index dce8edab0..dd8d29306 100644 --- a/install/sure-install.sh +++ b/install/sure-install.sh @@ -55,7 +55,7 @@ POSTGRES_DB=${PG_DB_NAME}/" \ -e "s|^APP_DOMAIN=|&${LOCAL_IP}|" /etc/sure/.env msg_ok "Configured Sure" -msg_info "Creating Service" +msg_info "Creating Services" cat </etc/systemd/system/sure.service [Unit] Description=Sure Service @@ -79,8 +79,31 @@ StandardError=journal [Install] WantedBy=multi-user.target EOF -$STD systemctl enable -q --now sure -msg_ok "Created Service" + +cat </etc/systemd/system/sure-worker.service +[Unit] +Description=Sure Background Worker (Sidekiq) +After=network.target redis-server.service + +[Service] +Type=simple +WorkingDirectory=/opt/sure +Environment=RAILS_ENV=production +Environment=BUNDLE_DEPLOYMENT=1 +Environment=BUNDLE_WITHOUT=development +Environment=PATH=/root/.rbenv/shims:/root/.rbenv/bin:/usr/bin:/usr/local/bin:/sbin:/bin +EnvironmentFile=/etc/sure/.env +ExecStart=/opt/sure/bin/bundle exec sidekiq -e production +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +EOF +$STD systemctl enable -q --now sure sure-worker +msg_ok "Created Services" motd_ssh customize