1

I am following the instructions in the "Installation as an init.d service (System V)" chapter of the Spring Boot Reference Guide.

I am not able to create a symbolic link to my Java app in init.d on Centos 6.6.

After I run

 sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp

when I try

 chmod 500 /etc/init.d/myapp

I get

chmod: cannot operate on dangling symlink `myapp'

When I change the permissions on a regular file instead of the symlink like this :

chmod 500 myapp.jar 

The symlink is of course still broken and I can't see it in service --status-all.

Also I can confirm that the symbolic link is not created correctly because I cannot start my app with

java -jar /etc/init.d/myapp

Note : When I just copy the entire jar to /etc/init.d/ everything works fine.

I don't even know is it considered "good" to create a symlink to a jar file or should I just copy it to /etc/init.d/ ?

2

To start the application you don't need to link the jar file. The binary you want to start is java with the jar file as an argument. To do that you need to create an init file (or sysyemd unit file of your system uses systemd). The script should handle at least a start and a stop argument to start and stop your application. The start would then set your java home and other items your application needs and then run the java command. There are a number of templates available for init scripts you can use.

  • ehmm i was following this example docs.spring.io/spring-boot/docs/current/reference/html/… . Anyhow thanks for answer. if you could give me link to one simple template script you mentioned. I come from a totally different world so pardon my ignorance – SeaBiscuit Jul 5 '17 at 8:47
  • It turns out my executable spring boot jar already contains embedded script "Fully executable jars work by embedding an extra script at the front of the file." ! – SeaBiscuit Jul 5 '17 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.