Skip to content

Commit

Permalink
Battles are active right now so this cannot be deployed yet, but shou…
Browse files Browse the repository at this point in the history
…ld put the nail in the deploy issue coffin. Work for #97
  • Loading branch information
jakethedev committed Dec 15, 2021
1 parent 3e52a36 commit 0ed361e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
8 changes: 5 additions & 3 deletions service/autoupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
set -e

###################################
# Auto updater script for simple projects
#
# Set as a BOT USER cron job, with the
# correct path, and your bot will
# auto update if there's a version
# change (or any package change)
#
# I set mine for every 2 minutes with a daily log cleanup. Ex:
#
#
# */2 * * * * /path/to/this/autoupdate.sh >> /var/log/botupdate.log 2>> /var/log/botupdate.log
# 0 2 * * * rm /var/log/botupdate.log
#
#
# - jakethedev
###################################

cd /opt/deploy/beatbattlebot
cp package.json package.old
git pull &> /dev/null
diff -w package.old package.json || systemctl restart beatbattlebot
diff -w package.old package.json || systemctl --user restart beatbattlebot.service
2 changes: 1 addition & 1 deletion service/beatbattlebot.service
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ RestartSec=60s
#StandardError=file:/var/log/bot.err

[Install]
WantedBy=multi-user.target
WantedBy=default.target
3 changes: 0 additions & 3 deletions service/cron_templates

This file was deleted.

33 changes: 19 additions & 14 deletions service/install-beatbattlebot.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
#!/usr/bin/env bash
# SYSTEMD SETUP
#### SYSTEMD SETUP
# NOTE If you have 236+, uncomment the StandardOutput/Error lines in the
# service if you'd like to output logs and errors to custom locations. Else
# it's journalctl for you

echo "Copying service file to /etc/systemd/system..."
# Installation of the unit file
TARGETDIR="$HOME/.config/systemd/user/"
echo "Copying service file to user unit directory..."
systemd --version
# If you have 236+, uncomment the StandardOutput/Error lines in the service if you'd like to output
# logs and errors to custom locations. Else it's journalctl for you
sudo cp beatbattlebot.service /etc/systemd/system/
cp beatbattlebot.service $TARGETDIR

echo "Reloading daemon, enabling and starting beatbattlebot service"
sudo systemctl daemon-reload
systemctl status beatbattlebot # It should say 'not loaded'
sudo systemctl enable beatbattlebot
sudo systemctl start beatbattlebot
# Enabling, activating, and kickstarting the unit file
systemctl --user daemon-reload
echo "=== The following should say 'not loaded', otherwise, good luck ==="
systemctl --user status beatbattlebot # It should say 'not loaded'
systemctl --user enable beatbattlebot
systemctl --user start beatbattlebot
echo "Sleeping, then checking status"
sleep 1
sudo journalctl -f
# You should see healthy output and a logged-in message
systemctl --user status beatbattlebot # It should say 'not loaded'

echo "Setting up logrotate"
sudo ln -s $(pwd)/logrotate.beatbattlebot /etc/logrotate.d/
# Quick logging config
# echo "Setting up logrotate"
# sudo ln -s $(pwd)/logrotate.beatbattlebot /etc/logrotate.d/
2 changes: 1 addition & 1 deletion service/logrotate.beatbattlebot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
notifempty
compress
postrotate
systemctl restart beatbattlebot
systemctl --user restart beatbattlebot
endscript
}

0 comments on commit 0ed361e

Please sign in to comment.