mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-17 00:01:14 +02:00
ReadMeABook: start the scheduler with the service (#17950)
Only GET /api/init creates the scheduled jobs and starts the scheduler; upstream's image calls it after every start, the LXC never did (#17945). An ExecStartPost hook now waits for the app and Redis like app-start.sh, and update adds it to existing installs.
This commit is contained in:
committed by
GitHub
parent
d3fa6c7ad9
commit
ae4d06b76d
@@ -31,6 +31,28 @@ function update_script() {
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! grep -q '^ExecStartPost=-/usr/local/bin/readmeabook-init$' /etc/systemd/system/readmeabook.service; then
|
||||||
|
msg_info "Starting the scheduler with the service"
|
||||||
|
cat <<'EOF' >/usr/local/bin/readmeabook-init
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Upstream's image calls /api/init after every start: it creates the scheduled jobs and starts the scheduler
|
||||||
|
url="http://127.0.0.1:${PORT:-3030}"
|
||||||
|
for _ in $(seq 1 60); do curl -sf -o /dev/null "$url/api/health" && break; sleep 1; done
|
||||||
|
for _ in $(seq 1 30); do [[ "$(redis-cli ping 2>/dev/null)" == PONG ]] && break; sleep 1; done
|
||||||
|
for attempt in 1 2 3 4 5; do
|
||||||
|
curl -sf -o /dev/null "$url/api/init" && exit 0
|
||||||
|
sleep "$attempt"
|
||||||
|
done
|
||||||
|
echo "ReadMeABook did not answer /api/init, scheduled jobs will not run" >&2
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/bin/readmeabook-init
|
||||||
|
sed -i '/^ExecStart=/a ExecStartPost=-/usr/local/bin/readmeabook-init\nTimeoutStartSec=180' /etc/systemd/system/readmeabook.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl restart readmeabook
|
||||||
|
msg_ok "Started the scheduler with the service"
|
||||||
|
fi
|
||||||
|
|
||||||
if check_for_gh_release "readmeabook" "kikootwo/ReadMeABook"; then
|
if check_for_gh_release "readmeabook" "kikootwo/ReadMeABook"; then
|
||||||
msg_info "Stopping Service"
|
msg_info "Stopping Service"
|
||||||
systemctl stop readmeabook
|
systemctl stop readmeabook
|
||||||
|
|||||||
@@ -63,6 +63,20 @@ fi
|
|||||||
msg_ok "Built ReadMeABook"
|
msg_ok "Built ReadMeABook"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
|
cat <<'EOF' >/usr/local/bin/readmeabook-init
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Upstream's image calls /api/init after every start: it creates the scheduled jobs and starts the scheduler
|
||||||
|
url="http://127.0.0.1:${PORT:-3030}"
|
||||||
|
for _ in $(seq 1 60); do curl -sf -o /dev/null "$url/api/health" && break; sleep 1; done
|
||||||
|
for _ in $(seq 1 30); do [[ "$(redis-cli ping 2>/dev/null)" == PONG ]] && break; sleep 1; done
|
||||||
|
for attempt in 1 2 3 4 5; do
|
||||||
|
curl -sf -o /dev/null "$url/api/init" && exit 0
|
||||||
|
sleep "$attempt"
|
||||||
|
done
|
||||||
|
echo "ReadMeABook did not answer /api/init, scheduled jobs will not run" >&2
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/bin/readmeabook-init
|
||||||
cat <<EOF >/etc/systemd/system/readmeabook.service
|
cat <<EOF >/etc/systemd/system/readmeabook.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=ReadMeABook
|
Description=ReadMeABook
|
||||||
@@ -75,6 +89,8 @@ User=root
|
|||||||
WorkingDirectory=/opt/readmeabook
|
WorkingDirectory=/opt/readmeabook
|
||||||
EnvironmentFile=/opt/readmeabook/.env
|
EnvironmentFile=/opt/readmeabook/.env
|
||||||
ExecStart=${START_CMD}
|
ExecStart=${START_CMD}
|
||||||
|
ExecStartPost=-/usr/local/bin/readmeabook-init
|
||||||
|
TimeoutStartSec=180
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user