I'm trying to use
systemctl to launch a process in a new, shared,
tmux session. I'm pretty sure my
tmux command is all set:
- I have the socket path set with a shared group.
- the service is executing under a user that's a member of the group
- I've tested from the CLI and it works; I can attach with another account.
The command looks like this:
tmux -S /tmp/tmux/sharedsesh new-session -s sharedsesh -d "/usr/bin/java server.jar"
However, when I put it in a new systemctl unit, I'm getting an error: "tmux: unknown option -- S". Since this is an uppercase S, I'm wondering if that means it doesn't have access to sockets or something?
[Unit] After=network.target [Service] WorkingDirectory=/srv/workspace PrivateUsers=true User=servhost Group=servhost ProtectSystem=full ProtectHome=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true ExecStart=/usr/bin/tmux -S /tmp/tmux/sharedsesh new-session -s sharedsesh -d "/usr/bin/java server.jar"
I've looked at the security directives under Service, but in the end I'm left with the error. And, I'm still wondering why it doesn't know about the S option - I'm running the same command as when I do it on the console, so why's it unknown?
== Edit =========
Ok, like so often is the case, just after posting I found my issue.
In fact my
ExecStart line is just fine - the error was from my subsequent controls, likely the next one: (bad syntax)
ExecReload=/usr/bin/tmux send-keys -S /tmp/tmux/sharedsesh "reload" Enter ^ -S should be here ^ send-keys here
In my defense, I was getting the error messages from
journalctl which did not show line numbers. Also, I didn't expect it because I didn't expect those to run.
Which leads to my next issue: now that I've fixed the syntax, it's clear that the service is stopping immediately after starting (and
Stopping timed out. Terminating. error to boot).
I guess my real issue is something wrong in my Unit file? Or does
systemd not like the way
tmux detaches? Or something else?