Jail Service Sometimes Starts, Sometimes Doesn't

I have one jail running icecast intalled from pkg. When my server reboots, the jails starts, but sometimes the icecast rc script does not start the icecast service, and sometimes it does.

I’ve tried 13.2 and 13.3 release jails running on TrueNAS CORE 13.0 and 13.3

So I’m trying to collect some reasons for this behavior. Why would a service sometimes start, and sometimes not start?
Could it be an iocage issue?

Hard to say. Does it require a working internet connection to start? Maybe something in the script (or a dependent service) checks for an internet connection?

I checked that. The “REQUIRED” field is commented so no to that.

I now have another jail on 13.3-RELEASE-p4 that has started acting this way.

I have to manually go in and start the service (meshcentral in this case) instead of it starting on its own.

Are there any rc related logs one could possibly look at to see what is going on?

Dont know if can be related to your case, but i face a strange similar problem. Created 3 jails, created a similar autostart script and a start one for all but only one of them could auto start properly. (Paperless, tika, gotenberg).
They finally auto-start properly only if i add the log retention in the function to call the start script, for example

paperless_start() {
echo “Starting paperless service” >> /var/log/paperless_service.log
su - paperless -c ‘/usr/local/sbin/paperless’ >> /var/log/paperless_service.log
}

Work, but

paperless_start() {
echo “Starting paperless service”
su - paperless -c ‘/usr/local/sbin/paperless’
}

Not work…
For me Is just no sense

I either daemonize or use pm2 to run things in my jails.

I deamonize everything I can as well. The latest jail I’m having trouble with is deamonized.

System specs? How many jails do you run?

Dell R520
Intel(R) Xeon(R) CPU E5620 @ 2.40GHz
64 GB ECC RAM
8 TB mirror

This system is running 14 jails.

One jail is hit and miss, sometimes the service starts, sometimes it doesn’t.

The other one (meshcentral) recently started never starting at all.

Did you try creating them from scratch?

Yes sir.

Icecast (the first jail) has its own built in rc script, but the one for meshcentral was created by me. It’s been working fine up till now. I will mention that I did update meshcentral, but I’m having a hard time linking the two events together.

The script for meshcentral is as follows.


#!/bin/sh

# MeshCentral FreeBSD Service Script

# PROVIDE: meshcentral
# REQUIRE:
# KEYWORD: shutdown

. /etc/rc.subr

name=meshcentral
user=meshcentral
rcvar=meshcentral_enable

: ${meshcentral_enable:="NO"}
: ${meshcentral_args:=""}

pidfile=/var/run/${name}/${name}.pid
command="/usr/sbin/daemon"
meshcentral_chdir="/usr/local/meshcentral/node_modules"
command_args="-r -u ${user} -P ${pidfile} /usr/local/bin/node ${meshcentral_chdir}/${name} ${meshcentral_args}"

load_rc_config $name
run_rc_command "$1"

dumb question; why do you have the default for meshcentral_enable as no?

EDIT: I’ll just put all my dumb questions in this one reply.

another dumb question: is the rc script executable (still)?

Yes to both of those. It starts fine with service meshcentral start and has been auto starting fine until a week ago.

Perhaps the upgrade of my jail to 13.3 introduced something new?

Mmmh… What about recreating the jails from scratch? If something went astray with the upgrade doing so would address it.

I’ll give that a shot.

1 Like

No go. Same issue.

Permissions? Permissions on /var/run…

There really isn’t too many moving parts here and I’m out of ideas.

Edit the rc script and place this somewhere at the top before any real code but after the #! line:

exec >/tmp/rc.log 2>&1
set -x

HTH,
Patrick

1 Like

That’s the default inside all standard rc scripts. It can then be overridden per service by placing SERVICE_enable="YES" into /etc/rc.conf.

Is this supposed to get it to autostart, or just show me why it’s not?