[12U] Unable to auto start jar inside a jail

Num3

Cadet
Joined
Jun 24, 2021
Messages
4
Hello all,
I am a noob of Truenas, and have only been messing around with it for the last few days.
The only thing stopping me from migrating to this great server is the fact i am not able to launch a jetty web server jar inside a jail.

I downloaded the jar into the ~ directory (default) and tried to run it from there.

I made a new rc script inside /etc/rc.d and it fires well from the console, but it does not launch after a restart or boot.
I also tried creating a rc.d directory inside /usr/local/etc and copied the script into it (now i can do service telemetria start|stop), but still no auto start.

Code:
#!/bin/sh

. /etc/rc.subr

name="telemetria"
rcvar=telemetria_enable

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name

telemetria_start()
{
    echo "Starting ${name}"
    cd ~/./ && nohup /usr/local/bin/java -jar ~/./Telemetria.jar > ~/./nohup.txt &
    echo "Started!"
}

telemetria_stop()
{
  pid=$(pgrep java)
  echo "Killing pid: ${pid}"
  kill $pid
}
run_rc_command "$1"


Can someone help me?
I think the problem is path or permissions related, is there any log i can check for that?

Thanks!
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

Num3

Cadet
Joined
Jun 24, 2021
Messages
4
If you can manually start it, it's probably just a question of handling the telemetria_enable=YES sysrc variable in your script to start it automatically.

Look at one of the examples here:
https://www.truenas.com/community/r...darr-lidarr-jackett-transmission-organizr.58/ (for example Sonarr has an RC file)
Thanks for your reply,

I have already executed telemetria enable | enabled and can confirm telemetria_enable="YES" is present on /etc/rc.conf and /usr/local/etc/rc.conf.
:\ , so there's is something else going on
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I have already executed telemetria enable | enabled and can confirm telemetria_enable="YES" is present on /etc/rc.conf and /usr/local/etc/rc.conf.
:\ , so there's is something else going on
Have a look at how it's done in the examples I linked... it looks different to how you're doing it.
 

Num3

Cadet
Joined
Jun 24, 2021
Messages
4
Have a look at how it's done in the examples I linked... it looks different to how you're doing it.
I have looked at the examples you sent and I was able to run the jail from the TrueNas console (not the jail one) with iocage exec telemetria service telemetria start and it worked like a charm.

My question is, how can i make TrueNas run that console command when it boots or the cage is started?
 

Num3

Cadet
Joined
Jun 24, 2021
Messages
4
--Update--
Just restarted the jail and now the same nas console command does not work o_O

I need a break, i will do a fresh install tomorrow and only create this jail using the info provided above.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
if the rc.d script handles it properly and _enable=YES is set, then it will, that's what I'm trying to tell you.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I'm also unsure about the option of cd within an rc.d script... perhaps that's it.

I'm aware that when using the daemon options, you can only do it with -C and it effectively will only cd to /
 
Top