Fix notification-delivery cron docs: cron may not be installed, /var/log/ needs root
This commit is contained in:
1 file changed
+25
-8
@@ -153,21 +153,38 @@ regardless of whether anything has actually delivered it yet.
|
|||||||
[stacks/infra/scripts/process-cron.sh](stacks/infra/scripts/process-cron.sh)
|
[stacks/infra/scripts/process-cron.sh](stacks/infra/scripts/process-cron.sh)
|
||||||
calls both endpoints for **every** business under `STACKS_DIR` in one
|
calls both endpoints for **every** business under `STACKS_DIR` in one
|
||||||
run, so a single crontab entry covers businesses added later too — no
|
run, so a single crontab entry covers businesses added later too — no
|
||||||
per-business cron line to maintain. Add this to the VPS's crontab
|
per-business cron line to maintain.
|
||||||
(`crontab -e`) once:
|
|
||||||
|
Many minimal cloud VPS images (including some Debian ones) don't ship
|
||||||
|
`cron` at all — `crontab -e` failing with `command not found` means this
|
||||||
|
first:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt update && sudo apt install -y cron
|
||||||
|
sudo systemctl enable --now cron
|
||||||
|
```
|
||||||
|
|
||||||
|
Then add this to the VPS's crontab (`crontab -e`) once — **not** `sudo
|
||||||
|
crontab -e`: run it as the same non-root user that already owns
|
||||||
|
`/opt/nextchair` (the one you've been running `git pull`/`docker build`
|
||||||
|
as), so the log file below is writable without needing root:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Deliver queued notifications every 2 minutes.
|
# Deliver queued notifications every 2 minutes.
|
||||||
*/2 * * * * STACKS_DIR=/opt/nextchair/stacks /opt/nextchair/stacks/infra/scripts/process-cron.sh notifications >> /var/log/nextchair-cron.log 2>&1
|
*/2 * * * * STACKS_DIR=/opt/nextchair/stacks /opt/nextchair/stacks/infra/scripts/process-cron.sh notifications >> /opt/nextchair/nextchair-cron.log 2>&1
|
||||||
|
|
||||||
# Refresh Google Reviews once a day.
|
# Refresh Google Reviews once a day.
|
||||||
0 3 * * * STACKS_DIR=/opt/nextchair/stacks /opt/nextchair/stacks/infra/scripts/process-cron.sh reviews >> /var/log/nextchair-cron.log 2>&1
|
0 3 * * * STACKS_DIR=/opt/nextchair/stacks /opt/nextchair/stacks/infra/scripts/process-cron.sh reviews >> /opt/nextchair/nextchair-cron.log 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
(Adjust `STACKS_DIR` if you cloned this repo somewhere other than
|
(Adjust `STACKS_DIR`/the log path if you cloned this repo somewhere other
|
||||||
`/opt/nextchair`.) To confirm it's working, or to flush a notification
|
than `/opt/nextchair`, or don't have write access to it — `/var/log/`
|
||||||
that's stuck pending right now, run either line's command by hand and
|
itself is **not** a safe default here: it needs root, and a crontab
|
||||||
check `/var/log/nextchair-cron.log` — a healthy run logs `<slug>
|
entry that can't write its own log file just silently produces no file
|
||||||
|
at all, which looks identical to "the job never ran.") To confirm it's
|
||||||
|
working, or to flush a notification that's stuck pending right now, run
|
||||||
|
either line's command by hand and check
|
||||||
|
`/opt/nextchair/nextchair-cron.log` — a healthy run logs `<slug>
|
||||||
process-notifications ok` for every business.
|
process-notifications ok` for every business.
|
||||||
|
|
||||||
## Updating after a code change
|
## Updating after a code change
|
||||||
|
|||||||
Reference in new issue
Block a user