Starting jackd -R on boot on Ubuntu Gusty -rt

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
Hello,

I'm having problems starting jackd on boot on Ubuntu Gutsy with kernel 2.6.22-14-rt. I had no problem on Ubuntu Feisty...

I created a /etc/init.d/jackd.sh script, I won't post it entirely here (even if it's not that complicated). Basically, it runs:
> sudo -u $JACKUSER `/home/me/.jackdrc`
I'm using SVN ffado drivers and the contents of my .jackdrc is as follows:
> /usr/bin/jackd -R -P70 -dfirewire -dhw:0 -r48000 -p512 -n3 -i4 -o10
I made the appropriate links in /etc/rc2.d/ (RL 2 is the default user/graphical one in Ubuntu) and others (using update-rc.d) but I get the following (weird) behaviour.
If $JACKUSER is me, the following error happens :
> cannot use real-time scheduling (FIFO at priority 10) [for thread -1208116544, from thread -1208116544] (1: Operation not permitted)
> cannot create engine
If $JACKUSER is root... jackd exits without any message (it seems to start correctly, and then exit immediately)

Note that I have _no_ problem running jack after boot (either using the aforementioned init script or running it directly)...

I tried running it as late as possible (even order 99) to ensure anything necessary has started, but it doesn't help.

Anyone has an idea how to work around this issue ?

Nicolas JOYARD
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Florian Paul Schmidt-2
On Thursday 22 November 2007, Nicolas Joyard wrote:
> I tried running it as late as possible (even order 99) to ensure anything
> necessary has started, but it doesn't help.
>
> Anyone has an idea how to work around this issue ?

Maybe it has to do with how PAM is used by login. If you do su $USER you won't
get a login shell and i guess no PAM negotiation has happened. Maybe you can
start bash as login shell which then runs jackd..

Just a shot in the dark though..

Flo


--
Palimm Palimm!
http://tapas.affenbande.org

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

David-71
In reply to this post by Nicolas JOYARD
On Thu, 22 Nov 2007 20:47:19 +0100
"Nicolas Joyard" <[hidden email]> wrote:

> Hello,
>
> I'm having problems starting jackd on boot on Ubuntu Gutsy with kernel
> 2.6.22-14-rt. I had no problem on Ubuntu Feisty...
>
> I created a /etc/init.d/jackd.sh script, I won't post it entirely
> here (even if it's not that complicated). Basically, it runs:
> > sudo -u $JACKUSER `/home/me/.jackdrc`
> I'm using SVN ffado drivers and the contents of my .jackdrc is as
> follows:
> > /usr/bin/jackd -R -P70 -dfirewire -dhw:0 -r48000 -p512 -n3 -i4 -o10
> I made the appropriate links in /etc/rc2.d/ (RL 2 is the default
> user/graphical one in Ubuntu) and others (using update-rc.d) but I
> get the following (weird) behaviour.
> If $JACKUSER is me, the following error happens :
> > cannot use real-time scheduling (FIFO at priority 10) [for thread
> -1208116544, from thread -1208116544] (1: Operation not permitted)
> > cannot create engine

Seems like a session setup issue, PAM wise. Depending on your distro,
configuration files may differ.

Here on Debian testing, su doesn't initialize system limits as login
does but it is just a matter of uncommenting one line in /etc/pam.d/su.

Make sure that you have something like :

session    required   pam_limits.so

in your PAM config file related to su, and that
/etc/security/limits.conf (this path may be distro dependent) is
properly configured to allow $JACKUSER to gain RT privileges.

HTH

--
David

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
> Maybe it has to do with how PAM is used by login. If you do su $USER you won't
> get a login shell and i guess no PAM negotiation has happened. Maybe you can
> start bash as login shell which then runs jackd..

> Here on Debian testing, su doesn't initialize system limits as login
> does but it is just a matter of uncommenting one line in /etc/pam.d/su.
>
> Make sure that you have something like :
>
> session    required   pam_limits.so
>
> in your PAM config file related to su,

Thanks for the suggestions, I'll have a look at that tonight. Plus I'll be an opportunity for me to understand what PAM does and how it does it :)

> and that
> /etc/security/limits.conf (this path may be distro dependent) is
> properly configured to allow $JACKUSER to gain RT privileges.

This one is already configured properly, as I can start jack manually after login without any problem.

Nicolas



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
>> Maybe it has to do with how PAM is used by login. If you do su $USER you won't
>> get a login shell and i guess no PAM negotiation has happened. Maybe you can
>> start bash as login shell which then runs jackd..
>
>> Here on Debian testing, su doesn't initialize system limits as login
>> does but it is just a matter of uncommenting one line in /etc/pam.d/su.
>>
>> Make sure that you have something like :
>>
>> session    required   pam_limits.so
>>
>> in your PAM config file related to su,
>
>Thanks for the suggestions, I'll have a look at that tonight. Plus I'll be an opportunity
>for me to understand what PAM does and how it does it :)

>
>> and that
>> /etc/security/limits.conf (this path may be distro dependent) is
>> properly configured to allow $JACKUSER to gain RT privileges.
>
>This one is already configured properly, as I can start jack manually after login
>without any problem.

Unfortunately I still don't manage to get jackd to start on boot. As a reminder, here's how I start jack in my init script :

sudo -u $JACKUSER jackd -R (...) >> $JACKLOG 2>&1 &

(I made $JACKLOG writable by everyone for testing purposes)
And here're the error messages :

cannot use real-time scheduling (FIFO at priority 10) [for thread -1208116544, from thread -1208116544] (1: Operation not permitted)
cannot create engine

First I triple-checked /etc/security/limits.conf just in case, and here's an excerpt that seems correct to me ($JACKUSER is of course a member of the audio group) :

@audio - rtprio 99
@audio - nice -19
@audio - memlock 512000

Then I tried changing /etc/pam.d/su, uncommenting the line David indicated, which changed nothing. Thinking /etc/pam.d/su wasn't affecting sudo, I tried two different things.

1) adding the following to /etc/pam.d/sudo

session     required    pam_limits.so # before the @include lines
@include common-session # after the two existing @include lines

That also changed nothing.

2) Changing the init script line launching jack to :

su $JACKUSER
jackd -R (...) >> $JACKLOG 2>&1 &
su root

Which cannot be the right way because in this case jackd doesn't even seem to run (nothing added to $JACKLOG)...

Finally, as Florian indicated, I tried :

bash -l -c "jackd -R (...)" >> $JACKLOG 2>&1 &

to force login and system limits initialization, but I still get the same error. I don't have a lot of knowledge about PAM but it already seems weird to me. I'm currently trying to get some documentation about it, still if anyone has additional ideas...

Nicolas

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Florian Paul Schmidt-2
On Friday 23 November 2007, Nicolas Joyard wrote:

> to force login and system limits initialization, but I still get the same
> error. I don't have a lot of knowledge about PAM but it already seems weird
> to me. I'm currently trying to get some documentation about it, still if
> anyone has additional ideas...

You could try using the realtime-lsm instead of trying to get your session
authenticated with PAM..

Regards,
Flo

--
Palimm Palimm!
http://tapas.affenbande.org

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
In reply to this post by Nicolas JOYARD
> I think that JAD will start Jack with the Session by the desktop
> environment. I'm a noob with this, but your Jack error seems to depend
> to limits.conf and not Pam.

Thanks for your help, but I don't think so : if it was because of limits.conf, jackd wouldn't start either after login. And actually it _does_ start without any problem when I run it after login (either manually or by launching qjackctl with my gnome session)

Nicolas

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
Actually you're still not there yet :)

I can start jack automatically on gnome startup without any problem. What I want is jack to start _before_ graphical login so that, for example, jack doesn't shut down and restart when restarting X. I'm using mpd and would like music to continue playing when I restart X for example....

(sorry Ralf for the double answer - at first I answered to you only)

Nicolas JOYARD



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
In reply to this post by Florian Paul Schmidt-2
> You could try using the realtime-lsm instead of trying to get your session
> authenticated with PAM..

Yeah, I'm gonna try that also; I didn't yet because the last time I did I had problems building the module.

Nicolas

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Mark Constable
On 2007-11-25 12:23 am, Nicolas Joyard wrote:
> Yeah, I'm gonna try that also; I didn't yet because the last time I did I
> had problems building the module.

FWIW this works for me...

su - myuserid -c "/usr/bin/jackd -R -dalsa -r48000 -p512 -n3 -D -Chw:1,0 -Phw:0,1 -i2 -o2" >> /var/log/startup.log 2>&1

startup.log is optional and must be chmod 666. I use
ArchLinux and I put the above in /etc/rc.local but I
am sure there is a similar general/misc startup file
for other distros. myuserid is in the audio group and
I have typical /etc/security/limits.conf settings.

[hidden email] ~ ps aux | grep jack
root      4609  0.0  0.0   2168   904 ?        S    00:20   0:00 su - myuserid -c /usr/bin/jackd -R -dalsa -r48000 -p512 -n3 -D -Chw:1
1000      4610  0.2  1.1  21724 21760 ?        SLsl 00:20   0:01 /usr/bin/jackd -R -dalsa -r48000 -p512 -n3 -D -Chw:1,0 -Phw:0,1 -i2 -o

--markc

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
> su - myuserid -c "/usr/bin/jackd -R -dalsa -r48000 -p512 -n3 -D -Chw:1,0 -Phw:0,1 -i2 -o2" >> /var/log/startup.log 2>&1

Oh ! Thanks Mark for this command, it now works perfectly ! I knew I wasn't using the right way with su.
Using this command line in the startup scripts, and uncommenting the line in /etc/pam.d/su with pam_limits.so makes it work.

Thanks again to everyone for your help :)

Nicolas

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
> this is on of the things that should be available as 'howto' in the net
> as a wiki with an index.

Yeah, I thought about that, I think I'm gonna do it someday, but I'm still asking myself where to put it (jack wiki -if it exists - , ubuntu wiki, ubuntu forum, debian, some linux audio-oriented website...)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Mark Constable
On 2007-11-26 03:24 am, Nicolas Joyard wrote:
> Yeah, I thought about that, I think I'm gonna do it someday, but I'm still
> asking myself where to put it (jack wiki -if it exists - , ubuntu wiki,
> ubuntu forum, debian, some linux audio-oriented website...)

One of many possibilities... http://alsa.opensrc.org/Jack

--markc

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

acebone
In reply to this post by Nicolas JOYARD

Nicolas JOYARD wrote
> su - myuserid -c "/usr/bin/jackd -R -dalsa -r48000 -p512 -n3 -D -Chw:1,0
-Phw:0,1 -i2 -o2" >> /var/log/startup.log 2>&1

Oh ! Thanks Mark for this command, it now works perfectly ! I knew I wasn't
using the right way with su.
Using this command line in the startup scripts, and uncommenting the line in
/etc/pam.d/su with pam_limits.so makes it work.

Thanks again to everyone for your help :)

Nicolas
Semi-noob here: Having the exact same problem - but what are the startup scripts that I need to put this line into?
Reply | Threaded
Open this post in threaded view
|

Re: Starting jackd -R on boot on Ubuntu Gusty -rt

Nicolas JOYARD
In reply to this post by Nicolas JOYARD
>This thread seems to answer all the questions - that is - all but
>one, it ends with a 'then you just put this line **insert command
>here** in the startup-scripts'. I'd love to, but I have no idea
>where the startup-script is.

If you just want jack to start with your session, you can just add qjackctl to session startup commands (I don't know the menu entries names in english, but you can simply run gnome-session-properties) and set it to start jack automatically when started.

If you want it to start _before_ your session, you can do as I did. Put the following script in a file named /etc/init.d/jackd, adjusting variables values to meet your setup:
-----------------------------------------------
#!/bin/bash

JACK_USER=username
JACK_LOG=a_file_writable_by_this_user
JACK_CMD="/usr/bin/jackd <jack options>"

do_endjack()
{
    JACK_PID=`pidof jackd`
    [ "$JACK_PID" ] && kill $JACK_PID
}

do_startjack()
{
    if [ "`cat $JACK_RC`" ]; then
        echo "`date` - Starting Jackd" > $JACK_LOG
        su - $JACK_USER -c "$JACK_CMD" >> $JACK_LOG 2>&1 &
    fi
}

case "$1" in
  start|"")
    do_startjack
    ;;
  restart|reload|force-reload)
    do_endjack
    sleep 2
    do_startjack
    ;;
  stop)
    do_endjack
    ;;
  *)
    echo "Usage: jackd.sh [start|stop|restart|reload|force-reload]" >&2
    exit 3
    ;;
esac

:
-----------------------------------------------

Make it executable (sudo chmod a+x /etc/init.d/jackd), then run the following command that will create the appropriate links to that script for each runlevel :

sudo update-rc.d jackd defaults 99

>I have Ubuntu 7.10 (Gutsy), which I installed the UbuntuStudio
>package on, using Synaptic, so now I have the realtime kernel,
>but of course I already have a sound-demon running (haven't
>got the faintest idea which), and that prevents jackd from starting.

Try seing if either esd or artsd are running and kill them before launching jack. I don't know how to deactivate them, maybe you can add commands to the script like kill `pidof artsd`... Or else I guess launching jack before them will prevent them from starting.

Nicolas JOYARD
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel