This doesnt work on startup, however if i run sudo systemctl start jesterbot.service it runs fine. I have installed it, reenabled it, and reloaded the daemon multiple times to make sure im not making a silly error yet it still isnt running on startup.
[pi@pi ~]$ systemctl status jesterbot.service
ā jesterbot.service - Run jesterbot
Loaded: loaded (/etc/systemd/system/jesterbot.service; enabled; vendor pre>
Active: inactive (dead) since Wed 2022-03-30 20:24:38 UTC; 20s ago
Process: 408 ExecStart=/usr/bin/tmux new-session -d -s jesterbot cd /home/p>
CPU: 18ms
Mar 30 20:24:38 pi systemd[1]: Starting Run jesterbot...
Mar 30 20:24:38 pi systemd[1]: jesterbot.service: Deactivated successfully.
Mar 30 20:24:38 pi systemd[1]: Started Run jesterbot.
lines 1-9/9 (END)
The command works fine, iāve copy and pasted it into terminal and it runs successfully, iāve checked the Require directory and there is jesterbot.service inside that, etc. Does anyone have any ideas?
The above is based on my experience with httpd and the following serverfault thread and bugzilla entry. After the last update, httpd failed on boot, but started fine manually when the system was up. Although, when I did a status on httpd, there were error messages that clearly indicated there was a timing issue. Double check the journal.
Unfortunately, this did not work
This is the journal log
[pi@pi ~]$ journalctl -b -u jesterbot.service
-- Journal begins at Fri 2021-10-29 16:07:00 UTC, ends at Thu 2022-03-31 16:07:>
Mar 31 16:07:38 pi systemd[1]: Starting Run jesterbot...
Mar 31 16:07:38 pi systemd[1]: jesterbot.service: Deactivated successfully.
Mar 31 16:07:38 pi systemd[1]: Started Run jesterbot.
ā jesterbot.service - Run jesterbot
Loaded: loaded (/etc/systemd/system/jesterbot.service; enabled; vendor pre>
Active: active (exited) since Thu 2022-03-31 16:11:00 UTC; 1min 59s ago
Process: 444 ExecStart=/usr/bin/tmux new-session -d -s jesterbot cd /home/p>
Main PID: 444 (code=exited, status=0/SUCCESS)
CPU: 16ms
Mar 31 16:10:59 pi systemd[1]: Starting Run jesterbot...
Mar 31 16:11:00 pi systemd[1]: Finished Run jesterbot.
And the logs
[pi@pi ~]$ journalctl -b -u jesterbot.service
-- Journal begins at Fri 2021-10-29 16:07:00 UTC, ends at Thu 2022-03-31 16:12:>
Mar 31 16:10:59 pi systemd[1]: Starting Run jesterbot...
Mar 31 16:11:00 pi systemd[1]: Finished Run jesterbot.
It needs to be Type=forking with tmux. However, because of tmux, you donāt see any logs. So nobody knows why it fails. The git commands might be a reason, but nobody can know.
You should really consider stop using tmux, it just makes you live harder with absolutely no benefit. Without tmux, you can use the journal to see whats going on, if it fails you can automatically restart or run extra services that notify you. You can run commands and then restart the service, or stop do something and start again. There is really no reason to use tmux for something like this.
For all we know, the service is fine, yet the remote target is unavailable for a brief moment before the git commands execute.
Here is an example of a script I invoke via a systemd service.
My ExecStart= points to this script:
#!/bin/bash
if nm-online -q --timeout 30;
then
if timeout 21s bash -c 'until ping -c1 -q remoteaddress.com > /dev/null 2>&1 ; do echo "Server unreachable! Retrying!" ; sleep 2s ; done'
then
# bunch of commands in here
echo "Rocket launch!"
else
echo "Server not reachable for over 20 seconds. Service aborted."
fi
else
echo "No network connection available. Service aborted."
fi
It will be in the journal. You can watch it live, filter it, it will be stored depending on your journald config.
The python command should be the only in ExecStart, you can use ExecStartPre for your git stuff. You can use multiple ExecStartPre commands. Use WorkingDirectory= , since the cd command will not work.
The Type= depends on the python application, but it will not be oneshot.
That works, thanks!
Im not entirely sure if this is related, but I now get a stage where putty ārefusesā my connection for about a minute, might my units be holding up the boot process and whatnot?