Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Daemon written in Java location

I'm currently writing a Java daemon. I'm writing a script that will have the standard daemon commands (start, stop, restart, status) and I'm trying to decide on where things should go when installing the daemon.

My current idea is:
PID File: /var/run/myapp.pid
Daemon Script: /etc/init.d/myapp
Java App (.jar): /usr/bin/myapp
Logs: /var/log/myapp.err, /var/log/myapp.log, /var/log/myapp.info (you get the idea)
Configs: /etc/myapp.conf (or /etc/myapp/configs-go-here if I have more than one in the future)

I'm still new to the Linux directory structure so if I'm doing something wrong let me know. Whats confusing me the most is that my Java app is a .jar file (archive) and not a binary. So does that mean that /usr/bin/ isn't the "right" place for it?

like image 508
William Avatar asked Dec 29 '25 02:12

William


2 Answers

You could put the .jar file in /usr/lib/myapp/myapp.jar and make the startup script do java -j /usr/lib/myapp/myapp.jar

Looking it from that side, the jar is effectively a library that the /usr/bin/java binary uses, so those locations look good to me.

like image 147
Arkaitz Jimenez Avatar answered Dec 31 '25 14:12

Arkaitz Jimenez


The /usr/lib/myapp/myapp.jar suggestion is on the right track, but /usr/lib is for architecture-specific files - since Java jar archives are platform-independent, /usr/share/myapp/myapp.jar is a better location.

like image 31
caf Avatar answered Dec 31 '25 16:12

caf