Unifi Service in a jail doesn't start

Yes, package after the “quarterly” to “latest” edit. And I have 8.3.32

image

Have the same problem - unifi service is not starting.
I have created a fresh jail and installed unifi8 - changed now updates from quarterly to latest.

Have had unifi8 running before but had problems with the new mongodb6 - so I decided to install fresh.

Mongodb is running, but unifi won’t:

but is not running:

I tried to find out the problem, but haven’t come too far.
From the unif service the follwoing command I have found:

When I try to run this it end in the following

Any ideas?

A change in Java that the port maintainer is not yet aware of? Remove that -f option from the rc.d script?

this does not do the trick - still not starting, looks now like:

Shouldn’t that command really be daemon instead of java? The JDK proper is invoked with the full path as the next set of arguments. So daemon -f -p ...

Yes it should. Can you post your unifi rc file? @cherup

Well - coming closer, but still need some more help.
When starting directly the java command it is working:

Here the unifi script which is not (yet) working:

This looks right.

It is working when I do the following commands manually:

But is not working when using the “-f -p /var/run/unifi/unifi.pid” command:

Not working

1 Like

Thank you. With your command it it started on my machine, too. But what can i do to make it start automatically when starting the iocage? How can i make it a service?

By installing it through pkg install unifi the service is already added to your jail. To make it start on startup, you need to sysrc unifi_enable=yes and for mongodb sysrc mongod_enable=yes

Does /var/run/unifi exist? Which user does it belong to?

Yes, it is /var/run/unifi exists and belongs to unifi:unifi

As I told before in Unifi Service in a jail doesn't start - #14 by mrMuppet
I tried it with a new pkg in stallation in a different iocage. But with the same result: unifi doesn start. :frowning:

I got infinitesimally closer on this with unifi8-8.4.62. The problem is that BSD rc scripts give you daemon for free, so deliberately invoking daemon in an rc script is redundant:

command=/usr/sbin/daemon
command_args="-f -p ${pidfile} ${unifi_java_home}/bin/java ${unifi_javaflags} -jar lib/ace.jar start"

This is wrong. The rc script will use daemon to wrap ${command} for you. My modified rc file now looks like this (truncated):

name=unifi
rc_debug=YES

rcvar=${name}_enable
load_rc_config ${name}

: ${unifi_enable:=NO}
: ${unifi_user:=unifi}
: ${unifi_group:=unifi}
: ${unifi_pidfile=/var/run/unifi/${name}.pid}
: ${unifi_chdir=/usr/local/share/java/unifi}
: ${unifi_java_home=/usr/local/openjdk17}
: ${unifi_javaflags="-Djava.awt.headless=true -Xmx1024M \
	-Djava.net.preferIPv4Stack=false \
	--add-opens java.base/java.lang=ALL-UNNAMED \
	--add-opens java.base/java.time=ALL-UNNAMED \
	--add-opens java.base/sun.security.util=ALL-UNNAMED \
	--add-opens java.base/java.io=ALL-UNNAMED \
	--add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED"}

pidfile="${unifi_pidfile}"
procname=${unifi_java_home}/bin/java
command="${unifi_java_home}/bin/java"
command_args="${unifi_javaflags} -jar lib/ace.jar start"

Note the addition of rc_debug which will show you what the script is actually doing, and the addition of ${unifi_pidfile}, which the rc framework will manage for you.

Unfortunately, it still doesn’t work – service unifi onestart debug output indicates that it’s launched the Java program, and netstat -an in another terminal shows network ports opening and closing, but the Web server proper never becomes available, and you never get the command prompt back (need to kill the server from another terminal if ^\ doesn’t work). I have not yet tried purging and reconstructing the jail from scratch. I’m wondering if it’s some subtle jail configuration issue – I haven’t been able to mount procfs, for example.

iocage set mount_procfs=1 <jailname>

I’m trying to update to UniFi 8 myself, created a new 13.4-RELEASE jail and used pkg install unifi8, everything appeared to go fine, but I can’t get the service to start either. Status screen at the bottom of TrueNAS says: truenas kernel: pid ##### (daemon) , jid 8, uid 975: exited on signal 12

number varies.

I have no idea what this means and I’m not finding a lot on line to explain it, I find info on “signal 11” and “signal 6” but not 12.

After a little more digging I found several of these entries in the cron log file that corresponded with my attempts to start the unifi service:
/usr/sbin/cron[18295]: (CRON) WARNING (madvise() failed)