mirror of
https://github.com/msfjarvis/server-config.git
synced 2024-06-03 04:08:58 +05:30
systemd: run goaccess run every 10 minutes in non-live mode
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
4994dd060a
commit
8ee6ac80de
12
systemd_units/goaccess-update.timer
Normal file
12
systemd_units/goaccess-update.timer
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Run goaccess every 10 minutes to update statistics
|
||||
Requires=goaccess.service
|
||||
|
||||
[Timer]
|
||||
Unit=goaccess.service
|
||||
OnUnitInactiveSec=10m
|
||||
RandomizedDelaySec=10m
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -10,7 +10,7 @@ RestartSec=2s
|
|||
Type=simple
|
||||
User=caddy
|
||||
Group=caddy
|
||||
ExecStart=/usr/bin/goaccess --log-format=VCOMMON --ws-url=wss://stats.msfjarvis.dev/ws --output=/var/www/stats.msfjarvis.dev/index.html --log-file=/etc/logs/requests.log --no-query-string --anonymize-ip --double-decode --real-os --compression=zlib --real-time-html
|
||||
ExecStart=/usr/bin/goaccess --log-format=VCOMMON --output=/var/www/stats.msfjarvis.dev/index.html --log-file=/etc/logs/requests.log --no-query-string --anonymize-ip --double-decode --real-os --compression=zlib
|
||||
Restart=always
|
||||
|
||||
# Security
|
||||
|
|
|
@ -9,6 +9,7 @@ function prettyPrint() {
|
|||
|
||||
# Grab all service names
|
||||
declare -a services=('caddy' 'goaccess' 'mirror-bot' 'mirror-bot-2' 'uno-bot' 'walls-bot' 'walls-bot-rs')
|
||||
declare -a timers=('goaccess-update')
|
||||
|
||||
# Now loop through each service and install it
|
||||
for service in "${services[@]}"; do
|
||||
|
@ -29,3 +30,18 @@ for service in "${services[@]}"; do
|
|||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for timer in "${timers[@]}"; do
|
||||
if [ "${1}" ] && [[ ${timer} != "${1}" && "${timer}.timer" != "${1}" ]]; then
|
||||
continue
|
||||
fi
|
||||
prettyPrint "Checking root access"
|
||||
sudo -v || return 1
|
||||
prettyPrint "Installing ${timer}"
|
||||
sudo cp -v "${timer}.timer" /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
if [ -z "${NO_RESTART}" ]; then
|
||||
prettyPrint "Enabling ${timer}"
|
||||
sudo systemctl enable "${timer}.timer"
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue
Block a user