Starting jack_capture with jack.service in a tmux session

#1

Hey!

Trying to add my old script to start a jack_capture instance in tmux (to be able to join into that session to see if everything is running correctly) brings some new problems:

jack is started as user jack which has no bash access and thus makes things difficult. So I guess I need a script which starts tmux as user patch and inside it an instance of jack_capture as user jack to get all the rt things going? This is getting tricky … any ideas?

If I start my script manually I see that everything works in tmux:

patch@MiCROLABS-P3:~$ jack_capture -c 2 -mb -tm -f wav --filename-prefix ABC-TEST- --hook-close ./hookstop.sh --hook-timing ./hookstart.sh
>>> Warning. Could not set higher priority for a SCHED_OTHER process using setpriority().
>>> Waiting to start recording of "ABC-TEST-05.wav"
>>> Press <Ctrl-C> to stop recording and quit.
   |"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""|
00:|-----------Press <Return> to start recording------------|
01:|-----------Press <Return> to start recording------------|
Buffer: 3.99s./11.99s   Time: 0.00m.   DHP: [ ]  Overruns: 0  Xruns: 0

but the warnings indicate the above …no high prio for this.

My script looks like this:

#!/bin/bash
/usr/bin/jack_wait -w
tmux new-session -d -s jackd
tmux new-window -t jackd -n Jack Capture -d
sleep 1
tmux send-keys -t jackd:0 'jack_capture -c 2 -mb -tm -f wav --filename-prefix ABC-TEST- --hook-close ./hookstop.sh --hook-timing ./hookstart.sh' C-m 

Any idea how to approach this?

0 Likes

#2

As long as the environment from /etc/environment is imported into the current session, you can run jack_capture as ‘patch’ user. It should happen by default, but if it doesn’t, you can force it by putting this in your script:

. /etc/environment # Put it above jack_wait

Try going through the following guide:

http://jackaudio.org/faq/linux_rt_config.html

At the last step, add ‘jack’ user also to the realtime group, let us know how it goes!

1 Like

#3

I don’t understand why there is no realtime group already? I thought this is already done in Patchbox OS?

usermod -a -G realtime jack
usermod: group 'realtime' does not exist

Should I do it anyways? How does the kernel handle this group realtime? There is a group called audio in Patchbox OS - where jack is already part of (

Edit: okay, the warning is gone by adding the line

* - nice -20 into /etc/security/limits.conf

found it here: https://linuxmusicians.com/viewtopic.php?t=11454#p46621

0 Likes

#4

Okay, since this works more or less … I am trying to figure out why my systemd which launches the script is behaving totally differently as if I launched the script manually - now I get even more Warnings/Errors:

jack_capture -c 2 -mb -tm -f wav --filename-prefix ABC-TEST- --hook-close ./hookstop.sh --hook-timing ./hookhook-timing ./hookstart.sh
Cannot lock down 82287136 byte memory area (Cannot allocate memory)
>>> Warning. Could not set higher priority for a SCHED_OTHER process using setpriority().
Cannot use real-time scheduling (RR/70)(1: Operation not permitted)
JackClient::AcquireSelfRealTime error
0 Likes

#5

Can you show us your entire .service file? All systemd services start with ‘empty’ environment, this could be the cause. The EnvironmentFile=/etc/environment is mandatory for services working with Jack backend.

0 Likes

#6
Description=Jack Capture autostart daemon
Wants=jack.service
After=multi-user.target

[Service]
Type=forking
EnvironmentFile=/etc/environment
User=patch
Group=realtime
ExecStart=/home/patch/jack-capture-tmux.sh

[Install]
WantedBy=jack.service

This is how it looks right now …after a lot unsuccessful tinkering

0 Likes

#7

One step closer again! Got rid of all the errors and warnings!

[Unit]
Description=Jack Capture autostart daemon
Wants=jack.service
After=multi-user.target

[Service]
Type=forking
Environment="XDG_RUNTIME_DIR=/run/patch/1000" # this was fixing all the errors
EnvironmentFile=/etc/environment
User=patch
Group=realtime
ExecStart=/bin/bash /home/patch/screen-test.sh # adding /bin/bash was fixing a new "bug"

[Install]
WantedBy=jack.service
2 Likes