How to auto-start Java application in jail?

Smoerrebroed

Cadet
Joined
Jan 29, 2022
Messages
3
Hi All,

first off: I have searched through the forums quite a bit, but so far I haven't found a solution that works for me, so hopefully I can get to something workable by posting this. If I have overlooked anything, please accept my apologies.

The title says it all: I am looking for a way to start a Java application (SteVe, to be precise) inside a jail when that jail starts up. What seems to be causing (some of) the problems is the fact that this application is outputting both to stdout and to stderr, and it doesn't come with a built-in daemon mode, so the only way to start it up is by issuing

$ java -jar steve.jar

What I have tried so far:

  • Putting the startup command as exec_poststart in the jail
  • Putting the startup command into /etc/rc.local
  • Creating a script in /etc/rc.d
  • Running it as a post-init command from TrueNAS
  • All of the above I have tried with and without various redirections, backgrounding and nohup modifiers.
  • Also, because it would actually be helpful to reattach to the running process in a terminal, I have tried screen as well. (Looks like this fails due to the lack of a PTY IIUIC.
Needless to say, none of the above has worked for me - in the automatic startup scenario, that is. Trying all of those approaches manually seems to work, but not when wired up with the automated processes.

So, the question is: What am I missing here? Is there any foolproof way of doing this? Any advice will be highly appreciated. Many thanks in advance!

Smoerrebroed
 

Smoerrebroed

Cadet
Joined
Jan 29, 2022
Messages
3
*bump* This has been kind of sitting in my pipeline, but now I'll need to make this work. Any ideas? I'm running on TrueNAS Core 12U8.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
I would try using daemon. The problem with the rc environment is that when it gets to the end, init spawns getty, and it's basically a new login environment, so the system cleans up old references to the controlling tty.
 
Top