Kyrne And I'm coming back here to
- Thank @Kyrne for being available at stupid-o-clock because of our differing time zones
- Let everyone know that if you are using plesk, you should go for Option 2 in the config (SSL handshake and cert pem). The reason for this is that plesk places NGINX config all over the place. It's tough to track down, and will be overwritten by updates as the files are generated dynamically.
Additionally, plesk doesn't support @reboot
in crontab -e
and nohup
doesn't exactly work very well either - even with respawn
.
Based on this, I had little choice other than to use a script that executes every 5 minutes. This looks like the below for anyone else who needs to use it
#!/bin/bash
cd /var/www/vhosts/phenomlab.com/forum.phenomlab.com
php flarum websockets:serve
for pid in $(pgrep -f websockets.sh); do
if [ $pid != $$ ]; then
echo "[$(date)] : Websocket : Process is already running with PID $pid" | tee -a /var/www/vhosts/phenomlab.com/backup/websockets.log
exit 1
else
echo "[$(date)] : Starting Websocket with PID $pid" | tee -a /var/www/vhosts/phenomlab.com/backup/websockets.log
php flarum websockets:serve
fi
done
Obviously, substitute my paths above for your own 🙂
Now onto the bit that matters. Websockets is fast. Like, superfast, doesn't send your JSON info off to another third party service you can't control, and is compliant with GDPR - an absolute MUST for my forum in particular.
Don't forget to disable DEBUG when you're done 🙂