ahdinosaur / ssb-pub

easily host your own Secure ScuttleButt (SSB) pub in a docker container
http://butt.nz/
GNU Affero General Public License v3.0
158 stars 25 forks source link

add cron job to ensure docker services are always up #12

Closed ahdinosaur closed 5 years ago

ahdinosaur commented 6 years ago

continuation from #10

at the moment, there is still a breaking case where the sbot or healer docker services go down (despite the docker config to keep them always running unless stopped).

i also notice that docker start sbot is idempotent, meaning if sbot is already running it won't change anything, but if sbot is not running it will start it.

so, we should add to the documentation a section about adding two cron jobs. on debian, we only need to run:

echo "docker start sbot" | tee /etc/cron.hourly/sbot && chmod +x /etc/cron.hourly/sbot
echo "docker start healer" | tee /etc/cron.hourly/healer && chmod +x /etc/cron.hourly/healer

/cc @mixmix @soapdog

mixmix commented 5 years ago

Hey mikey I don't think this worked for me, I think i told you that on scuttlebutt. Would love to debug with you sometime

On Tue, 25 Sep 2018, 14:54 Mikey, notifications@github.com wrote:

Closed #12 https://github.com/ahdinosaur/ssb-pub/issues/12 via 5e2d2f6 https://github.com/ahdinosaur/ssb-pub/commit/5e2d2f672c377f1c501dff0f45eb0611a0c2a938 .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ahdinosaur/ssb-pub/issues/12#event-1864618860, or mute the thread https://github.com/notifications/unsubscribe-auth/ACitnkmimmkKmZJvovsFCy108RGR8cFxks5ueZsBgaJpZM4WmEWL .

ahdinosaur commented 5 years ago

@mixmix yeah, it's not working for me either, i'm not sure why i thought i was working but my servers have been going down occasionally meow. keen to debug. :heart:

ahdinosaur commented 5 years ago

gosh i'm silly, it wasn't working and is a real simple fix to get it to work.

first i checked the cron service logs:

journalctl -u cron.service

the cron.hourly scripts is clearly running, a bunch of junk like:

Oct 19 06:17:01 ssb-pub CRON[15809]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Oct 19 06:17:01 ssb-pub CRON[15808]: (CRON) info (No MTA installed, discarding output)

i find a relevant stackoverflow post: https://stackoverflow.com/questions/14647447/cronjob-cron-daily-does-not-run-debian

says to try running the command the cron service is running:

run-parts --report /etc/cron.hourly

and yep, it's broken:

root@ssb-pub:~# run-parts --report /etc/cron.hourly
/etc/cron.hourly/healer:
run-parts: failed to exec /etc/cron.hourly/healer: Exec format error
run-parts: /etc/cron.hourly/healer exited with return code 1
/etc/cron.hourly/sbot:
run-parts: failed to exec /etc/cron.hourly/sbot: Exec format error
run-parts: /etc/cron.hourly/sbot exited with return code 1

i guess that it's because the scripts don't have a shebang, so i give each a wee #!/bin/sh, and boom:

root@ssb-pub:~# run-parts --report /etc/cron.hourly
/etc/cron.hourly/healer:
healer
/etc/cron.hourly/sbot:
sbot