Skip to main content
Topic: Trying to set up Runit service for Ices2 Stream Server (Read 971 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Trying to set up Runit service for Ices2 Stream Server

I created a service directory
Code: [Select]
/etc/runit/sv/ices
and created a run script in that directory. The run script is as follows:

Code: [Select]
#!/bin/sh
exec ices /etc/ices2/ices-playlist.xml

I also created a symbolic link from the created directory into the services directory. I have tried the following forms:

Code: [Select]
ln -s /etc/runit/sv/ices /run/runit/service/ices/
ln -s /etc/runit/sv/ices/ /run/runit/service/ices/
ln -s /etc/runit/sv/ices /run/runit/service/
ln -s /etc/runit/sv/ices/ /run/runit/service

If I run the command(s)
Code: [Select]
ices /etc/ices2/ices-playlist.xml
exec ices /etc/ices2/ices-playlist.xml

directly, the streaming server correctly starts and I can listen to the audio on the other end. If I run
Code: [Select]
sv start ices
, I get the following error:

Code: [Select]
timeout: down: ices: 1s, normally up, want up

checking
Code: [Select]
sv status ices
yields the same thing. Checking ps for ices pid also shows that there is no ices process running.

If I try:

Code: [Select]
sv stop ices
runsv /etc/runit/sv/ices

I get the following error:
Code: [Select]
runsv /etc/runit/sv/ices: fatal: unable to lock supervise/lock: temporary failure

Deleting the lock file at /etc/runit/sv/ices/supervice/lock appears to have no effect.

I have double checked that the run file is executable, and have granted 777 permissions on ALL FILES that are touched in this process. I'm at my wits end.

All I want to do is startup the ices streaming server on boot. please, for the love of god, what I am I doing wrong here?

Re: Trying to set up Runit service for Ices2 Stream Server

Reply #1
To make sure they are no stray process, restart your system.
What output do you then get when you run as root : /run/runit/service/ices/run

Re: Trying to set up Runit service for Ices2 Stream Server

Reply #2
After shutting down the system and rebooting, running /run/runit/service/ices/run directly succesfully starts the ices streaming server and all is well on that end. Unfortunately, I rebooted again to see if the service would start automatically, and to no avail. The process doesn't show up at all on system boot.

I also tried to run ices /etc/ices2/ices-playlist.xml from inside /etc/rc.local:

Code: [Select]
# /etc/rc.local -- rc.local for Artix Linux
#
# Enter your custom commands here. It will be executed on stage 2
# before running services.

echo "rc.local started" > /tmp/rc.local.log

sleep 10
ices /etc/ices2/ices-playlist.xml

I added the echo statement so that I could verify that rc.local was actually run. And the /tmp/rc.local.log DOES actually show up, s I know that rc.local is getting executed. But the ices streaming server still isn't running on boot. :(

Help!!

UPDATE!!!!

I was able to find out a strong lead! In /var/log/ices2/ices.log, I found the following:

Code: [Select]
[2021-09-30  00:26:17] EROR stream/ices_instance_stream Failed initial connect \
to cast.kohlodt.org:8000 (Couldn't connect)
[2021-09-30  00:26:17] DBUG input/input_loop An instance died, removing it
[2021-09-30  00:26:17] DBUG input/input_flush_queue Input queue flush requested
[2021-09-30  00:26:17] INFO input/input_loop All instances removed, shutting do\
wn...
[2021-09-30  00:26:17] INFO ices-core/main Shutdown complete

So it looks like runit IS starting the ices server, but it also looks like networking (and therefore the ability to connect to the icecast server on my vps) hasn't yet been set up yet. As a result, the ices server shuts itself down.

The same issue happens with rc.local, apparently, because rc.local is run before the other services on the system are brought up.

So how do I do this? How do I make sure the service starts after networking is fully available and brought online? I tried having the run script sleep for 10 seconds, but this doesn't seem to work. I also tried adding
Code: [Select]
sv start connmand || exit 1
to te run script, but this also doesn't seem to be working, either. What's the correct way to do this?

Thanks for any and all HALP!!!!

:Edit: OH Wait... if the networking issue was the only thing, then I'd still be able to start the service using sv after logging in. So there must be something else going on...

For whatever reason when ices is started as a runit service, the ices log contains an error that the server can't connect to the icecast vps server upstream. But when I run ices manually without it being a runit service, the ices server connects upstream just fine. So what on earth could be going on... ? Hurm...

I'm going to keep digging, but any and all help is GREATLY APPRECIATED!!!

ANOTHER UPDATE!!!

So it turns out that adding things like sleep 10 and `sv start connmand || exit 1` was causing issues because the run scripts were always exiting and never actually running the actual command to start ices.

By eliminated all extraneous detail from the run script, and only using:
Code: [Select]
#!/bin/sh
exec ices /etc/ices2/ices-playlist.xml

I was able to check against just that single line of code executing. And this led to a discovery:

Upon booting, the same issue happens.  The ices server can't immediately connect to my icecast vps and the service shuts down and doesn't start back up. Trying to run `sv start ices` just results in a timeout.

HOWEVER!!!

If I delete /etc/runit/runsvdir/current/ices/supervise/lock, and THEN I run
Code: [Select]
runsv /etc/runit/runsvdir/current/ices
, the ices server starts up!!! But also runsv doesn't return. The terminal just hangs as the ices server runs in the foreground.

So... I think the issue is that somehow:

1) on boot up the ices service needs networking to be running, but it's definitely not yet. And...
2) maybe there is some difference beween sv and runsv that I don't know about, although I have no idea if runit is trying to run each service at boot using sv, runsv, and/or what configuration tasks I need to do to make sure the correct commands are called.

Does anyone have any more information on this?

I've tried searching on google and duckduckgo for how to specify runit service dependencies. But the only hits I got were the following web site:

http://smarden.org/runit/

Which seems to be the official site of runit upstream. But surely that can't be the only place with documentation on this init system? Also, the documentation that WAS available from that source was... it seemed patchy to non-existent, and very out of date. There was only a single paragraph on service dependencies, and it basically amounted to saying "don't worry about it. Dependencies are handled automatically".

Except they are obviously not in my case. So what the hell?

Re: Trying to set up Runit service for Ices2 Stream Server

Reply #3
Runit is not a service manager so it does not have any way to handle dependencies. Everything is just started at the same time in stage two. To work around this, some scripts do a primitive check. You could do something similar to check if a network is up or not. If not, just exit 1. Runit will automatically try to bring the service up again and thus you re-run the check. This would repeat until it works.

For example, the ntp-runit script has this line at the beginning.
Code: [Select]
 [ "$(ip route | awk '/^default/{print ($3!="")+($5!="")}')" = "2" ] || exit 1 

You could give that a try.

Re: Trying to set up Runit service for Ices2 Stream Server

Reply #4
Hey Dudemanguy!

So, I've added various different checks to the run script, but am getting the same issue. The current run script is as follows:

Code: [Select]
#!/bin/sh                                                                                                                                                                                      

`ifconfig | grep -q "192.168.1.50"` && exec ices /etc/ices2/ices-playlist.xml \
                                            || sleep 1 && exit 1

So essentially I'm just checking ifconfig to see if the ip address for the machine has been set by the gateway dhcp server.

The thing that's bugging me is that runit doesn't seem to be attempting to restart the service at all. And trying to start the service via `sv` always ends up in a time out.

If I increase the wait time with the -w option like so:

Code: [Select]
sv -w 25 start ices

Then sv will actually report that ices starts! And it even gives a pid number!

Code: [Select]
sv -w 25 start ices
ok: run: ices: (pid 1603) 0s

Unfortunately, checking the status of ices immediately after shows that the service is down. And I still get the issue with runsv reporting an issue with not being able to remove the lock files.

So... I'm sorry. I really wanted to get on board the runit train. But at this point, I think my frustration is turning into bitter disappointment. I'm going to try my luck with a different init system. This is... just way too much effort, and... after providing as much information as I have on my own research, I think I'm feeling a little let down, is all.

Thanks to everyone who gave advice and tried to help. Peace out.

Re: Trying to set up Runit service for Ices2 Stream Server

Reply #5
Can you force runit to restart the service when you start X?

Something like
Code: [Select]
sudo sv restart ices &

In your .xinitirc?

Although that requires you to be able to execute sudo sv without a pass word, which may not be something you are comfortable with.

 

Re: Trying to set up Runit service for Ices2 Stream Server

Reply #6
Hey Dudemanguy!

So, I've added various different checks to the run script, but am getting the same issue. The current run script is as follows:

I don't believe the check you wrote is correct. What will happen is that the grep will indeed fail but because of the && the following binary will always be executed and thus you have the same problem as you always have. For this trick to work, your check needs to be immediately exited if it fails. Only if it succeeds should you actually try to exec into the binary. I'll just quote the ntp-runit script in its entirety.

Code: [Select]
#!/bin/sh
# Thanks to replabrobin for the network check!
[ "$(ip route | awk '/^default/{print ($3!="")+($5!="")}')" = "2" ] || exit 1
exec ntpd -g -u ntp:ntp -n >/dev/null 2>&1

Note that if the conditional at the top fails, the script immediately exits 1. The following line is not executed.

That said, dependency management of services on runit is inherently a bunch of workarounds. Unfortunately, network detection itself is basically a bunch of workarounds everywhere. Even on systemd, I think it technically is only "proper" (i.e. can react to it in an event-based manner) if you use systemd-networkd. openrc and s6 both have some network detection methods implemented at least.