Ubuntu – Start jackd with realtime priority with upstart

jackrealtimeupstart

I'm trying to start jackd with realtime priority at boot with an uptstart script but with no success so far. I'm using ubuntu server 14.04. My upstart version is 1.12.1.

The user and group I'm using in the script are allowed to use realtime priority, but when i run my upstart script that does not seems to matter.
Whenever i try to run it i get this on upstart log:

jackdmp 1.9.10
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2013 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
Cannot create thread 1 Operation not permitted
Cannot create thread 1 Operation not permitted
Cannot create thread 1 Operation not permitted
JACK server starting in realtime mode with priority 70
Cannot lock down 82274202 byte memory area (Cannot allocate memory)
Cannot create thread 1 Operation not permitted
ERROR: messagebuffer not initialized: libffado 2.1.9999- built Oct 19 2013 16:01:07
ERROR: messagebuffer not initialized: 1408466326248438: Error (PosixThread.cpp)[ 161] Start: Cannot create realtime thread (1: Operation not permitted)
ERROR: messagebuffer not initialized: 1408466326248486: Error (PosixThread.cpp)[ 162] Start:  priority: 75
firewire ERR: FFADO: Error creating virtual device
Cannot attach audio driver
JackServer::Open failed with -1
Failed to open server

If i run it with my regular user it works fine.
My upstart script is a very simple one:

description "jackd"

start on stopped rc
stop on runlevel [06]


exec su radiola -c "jackd -R -P 70 -d firewire -r 44100 -n 3 -p 2048"

I have also tried to use the setuid and setguid stanzas and start-stop-daemon but it ended up with the same results that i just described.
Is there a way to make upstart start realtime process? If not, is there other solution to this problem?

Thank you.

Best Answer

This was answered in stackoverflow:

https://stackoverflow.com/questions/25412381/how-to-start-a-process-with-realtime-priority-jackd-with-upstart

Turn out that you have to use the stanzas:

limit memlock unlimited unlimited
limit rtprio 95 95