views:

249

answers:

2

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?

+1  A: 

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.

Arkaitz Jimenez
I never thought of it like that! I originally thought of the .jar file as a library but it felt weird since it was the application I was writing. But when you put it like that it makes perfect sense. Thanks!
William
Beware of classpath hell ;) You may have to revisit your MANIFEST just in case your daemon depends on other libraries (and you used relative paths)
Andreas_D
+1  A: 

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.

caf