I had it working before but I lost everything and reinstalled Ubuntu and I forgot how to make it work.
For anyone who runs a local Discourse on their computer, and has configured it to run on startup, please tell me how you did it.
The following is what I’ve tried.
I currently have ~/.local/bin/start-discourse:
#!/usr/bin/env bash
cd ~/softwares/discourse
bundle exec rails server -p 3030 2> ~/start-discourse-stderr.txt
and
~/.local/bin/start-discourse-daemon:
#!/usr/bin/env bash
daemon --name="local-discourse" bash start-discourse
both of which DO work. But I don’t want to run start-discourse manually everytime I login.
So there are a few things I’ve tried.
Using crontab -e and adding @reboot start-discourse don’t work.
Using “Startup applications preference” doesn’t work. Tried both start-discourse, start-discourse-daemon, and even sleep 60 && start-discourse-daemon … I tried sleep command for most of methods here.
Adding .sh file into /etc/profile.d don’t work.
.bashrc … I keep forgetting that this gets run everytime a new terminal is opened. Sure, I could live with start-discourse-daemon running everytime open a terminal but I think there are better way, and it would only run only if I open the terminal.
Adding start-discourse-daemon into ~/.profile throws an error (into ~/start-discourse-stderr.txt) bundle: exec command not found. But it works when I logout and login again.
Using /etc/systemd/local-discourse.service following this hackernoon post doesn’t work. Yes I did enable it and start which it works when I run systemctl start local-discourse, but even when it’s enabled, it doesn’t work when rebooted.
I did try debugging with:
cd ~/softwares/discourse
bundle exec rails server -p 3030 > ~/start-discourse-stdout.txt 2> ~/start-discourse-stderr.txt
and even with
echo ($date "+%Y/%m/%d %H:%M:%S) Start script >> ~/start-discourse-log.txt
cd ~/softwares/discourse
echo ($date "+%Y/%m/%d %H:%M:%S) Changed directory, executing script >> ~/start-discourse-log.txt
bundle exec rails server -p 3030 > ~/stard/discourse-stdout.txt 2> ~/start-discourse-stderr.txt
echo ($date "+%Y/%m/%d %H:%M:%S) End of script >> ~/start-discourse-log.txt
and … for all or most of methods above does print all the logs into the ~/start-discourse-log.txt file. And even create ~/start-discourse-stdout.txt but this file would stay at size 0 forever.
If anything above worked for you please tell me which one.