K
K
korobey2019-08-26 14:10:12
icecast
korobey, 2019-08-26 14:10:12

Why is it impossible to start the process through systemd, while starting manually works?

Good afternoon!
Ices2, which is a client for icecast2, is started manually in the terminal with the command

[email protected]:~$ /usr/bin/ices2 /etc/ices2/ices-alsa.xml

At the same time, everything works, and in the ices.log log file I see the following output:
[2019-08-26  13:34:20] INFO ices-core/main IceS 2.0.2 started...
[2019-08-26  13:34:20] INFO input-alsa/alsa_open_module Opened audio device pulse
[2019-08-26  13:34:20] INFO input-alsa/alsa_open_module using 2 channel(s), 44100 Hz, buffer 500 ms 
[2019-08-26  13:34:20] INFO input-alsa/alsa_open_module Starting metadata update thread
[2019-08-26  13:34:20] INFO signals/signal_usr1_handler Metadata update requested
[2019-08-26  13:34:20] INFO audio/downmix_initialise Enabling stereo->mono downmixing
[2019-08-26  13:34:20] INFO audio/resample_initialise Initialised resampler for 1 channels, from 44100 Hz to 22050 Hz
[2019-08-26  13:34:20] INFO encode/encode_initialise Encoder initialising in VBR mode: 1 channel(s), 22050 Hz, quality 
[2019-08-26  13:34:20] WARN metadata/metadata_thread_signal Failed to open file "test" for metadata update: No such file or directory
[2019-08-26  13:34:20] INFO stream/ices_instance_stream Connected to server: localhost:8000/kupina

However, the unit I created, containing the same command,
[Unit]
Description=Ices Service
After=network.target
Requires=icecast2.service

[Service]
Type=simple
ExecStart=/usr/bin/ices2 /etc/ices2/ices-alsa.xml
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

trying unsuccessfully to start the process:
[email protected]:~$ systemctl status ices
● ices.service - Ices Service
   Loaded: loaded (/etc/systemd/system/ices.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2019-08-26 14:14:00 MSK; 4s ago
  Process: 14477 ExecStart=/usr/bin/ices2 /etc/ices2/ices-alsa.xml (code=exited, status=0/SUCCESS)
 Main PID: 14477 (code=exited, status=0/SUCCESS)

авг 26 14:14:00 bigboss-server systemd[1]: Started Ices Service.
авг 26 14:14:00 bigboss-server ices2[14477]: ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection re
lines 1-8/8 (END)

And in the log file it appears:
[2019-08-26  14:14:00] INFO ices-core/main IceS 2.0.2 started...
[2019-08-26  14:14:00] EROR input-alsa/alsa_open_module Failed to open audio device pulse: Connection refused
[2019-08-26  14:14:00] EROR input/input_loop Couldn't initialise input module "alsa"
[2019-08-26  14:14:00] INFO ices-core/main Shutdown complete

How to understand this and what needs to be done to make the process run through systemd?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-08-26
@dimonchik2013

right, obviously, it
’s possible to run it in the systemd from a specific user, try it from your

K
korobey, 2019-09-03
@korobey

Hallelujah!
The problem was unexpectedly solved by changing the device parameter in the ices-alsa.xml config from the pulse value to the plughw: 1.0 value,
where 1.0 is the designation of my external Scarlett 2i2 USB sound card:

[email protected]:~$ aplay -l
**** Список PLAYBACK устройств ****
карта 1: USB [Scarlett 2i2 USB], устройство 0: USB Audio [USB Audio]
  Подустройства: 1/1
  Подустройство №0: subdevice #0

At the same time, it should be noted that the standard access to the device in the form hw: 1.0 led to an error
INFO ices-core/main IceS 2.0.2 started...
EROR input-alsa/alsa_open_module Sample format not available: Invalid argument
EROR input/input_loop Couldn't initialise input module "alsa"
INFO ices-core/main Shutdown complete

PS
As it turned out later, in the scenario described above, Ices, running through systemd as root, has exclusive access to the sound card, not allowing pulseaudio to it, with all the ensuing consequences: for example, it is impossible to record from the card's output using Audacity or Ocenaudio programs. In pavucontrol, only "dummy exit" is found.
Therefore, I had to return to the launch option through the systemd / user service:
$ sudo xed /etc/systemd/user/ices.service

[Unit]
Description=Ices2 Service

[Service]
ExecStart=/usr/bin/ices2 /etc/ices2/ices-alsa.xml
Restart=always
RestartSec=20s

[Install]
WantedBy=default.target

$ sudo systemctl --user --global enable ices

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question