I have some scripts to start and stop a java application which using jenkins.
Check the port and kill pid if java is running. And then start the application.
Write the pid which running on specific port and kill. Then start the application.
Which one is more accurate? If I used second option I cannot run as a
systemd service. Because it is only killing accessing pid file creating while starting the application.