termux-services
termux-services copied to clipboard
runsv not running
On lineageos17.1
After install and restart and command
sv-enable tor
I get:
fail: tor: runsv not running
If runsv
is not running then $PREFIX/etc/profile.d/start-services.sh
has not been sourced. Did you open a new shell rather than restarting termux after installing termux-services?
Try source $PREFIX/etc/profile.d/start-services.sh
or restart termux and try again.
If it still does not work please give output of pstree
.
I really restarted termux. I even rebootet multiple times. I tried sourcing, still doesn't work.
pstree output in tmux:
?─┬─?───bash───tmux: client
└─tmux: server─┬─4*[bash]
└─bash───pstree
pstree output:
?─┬─?───bash───pstree
└─tmux: server───4*[bash]
What's your output of termux-info
?
Does source $PREFIX/etc/profile.d/start-services.sh
give you an error?
termux-info
:
Linux localhost 3.4.113 armv71 Android
Device Model: SM-9005
source $PREFIX/etc/profile.d/start-services.sh
gives nothing
Now sv-enable tor
gives:
warning: tor: unable to open supervise/ok: file does not exist
Still just tor
works.
In $PREFIX/etc/profile.d/start-services.sh
export SVDIR=$PREFIX/var/service
export LOGDIR=$PREFIX/var/log
(service-daemon start >/dev/null 2>&1 & )
In $PREFIX/var/service
is a directory, within a run (script), which starts tor (./run
)
After looking into this a bit (finally) it seem to happen when something goes wrong when runsv starts. If we delete the supervise folder for a running service then sv status
gives this error, but the service continues to run without issues, so it is not quite the same as here.
I can somewhat reliably create the issue for a log service by setting up a service + script, but adding some well-crafted sleep statements in the middle of the script. Running this:
cd $PREFIX/var/service
echo -e "#!/data/data/com.termux/files/usr/bin/bash\necho 1\nsleep 3" > foo/run
chmod u+x foo/run
sleep 2
mkdir foo/log
sleep 1
ln -s $PREFIX/share/termux-services/svlogger $PREFIX/var/service/$sv/log/run
sv status foo
then gives run: foo: (pid 28148) 3s; warning: foo/log: unable to open supervise/ok: file does not exist
occasionally, so I guess there is some sort of race condition happening.
It can be fixed quite easily by killing the runsv process (check PID with ps aux | grep runsv
), it then restarts and creates the supervise folder and everything works. Rebooting the phone also works, but I think that did not work when this situation happened "naturally" after installing with apt? Need to look into it more I guess