Centos 7 - how to start Java app requiring networking on boot with systemd
Hi Guys
I have a Java App that requires networking to be up. In the terminal, I start the app this way with the startverdi.sh script: (it runs in a screen): Code:
cd /usr/src/verdi I now what to do exactly the above, but when the system starts up. I have this systemd script - verdi.service - in /etc/systemd/system: Code:
Code:
systemctl enable verdi.service For example, I can access the app on 127.0.0.1 once I start it manually in a terminal, but if I reboot the system to have it start via systemd, it DOES start, but has no networking. The same is true if I do Code:
systemctl start verdi.service systemctl status verdi.service returns, after a reboot: Code:
verdi.service - VerDi How can I fix this and give my Java App network access when starting it via systemd, just as if I started it from a commandline in the terminal? Note I have Code:
After=network-online.target Thanks Stefan EDIT: I also disabled firewalld in case it was somehow interfering if the Java app was started via systemd, to no effect. The Java app is still not contactible the moment systemd kicks it off for me on system start. |
From the systemd website:
Quote:
|
Hi
Thanks for the reply! I use networkmanager - however, that was not the problem. I've managed to solve this in the meantime. It turns out I needed to change the verdi.service file I passed to systemd. I had to add a line Code:
WorkingDirectory=/usr/src/verdi ExecStart line. E. g. my verdi.service file now looks like this: Code:
The reason it was NOT working and it had no network connectivity was that SystemD (with me not specificing WorkingDirectory) started the app in the /etc/systemd/system folder, NOT the /usr/src/verdi where it should have started. It was therefore missing certain configuration files which obviously are not in /etc/systemd/system, but in /usr/src/verdi - among these config files is the one that tells the VerDi app which IP to use... and -that- was why it was not working - it was started by systemd in the wrong directory. So the verdi.service file was 99% correct, it just needed me to add the WorkingDirectory entry to get it to start the Java app in the correct location. Regards Stefan |
Nice that you solved the problem. Thanks for posting back the solution.
|
All times are GMT -5. The time now is 10:42 AM. |