I have written jenkins job for deploying my package into one of my servers. Am using debian package management system. Am updating all the packages of machine by sudo apt-get update
command and installing the required package by sudo apt-get install package_name
in a deployment_script (where we make .deb file and specify servers to install). Also am copying the script am using to start / stop package to /etc/init.d/package_name. This script can take parameters start / stop. In my debian postinst script I have mentioned /etc/init.d/package_name start to start the package. For deploying I'll just trigger the jenkins job and give deployment_script to the job. It can install package, then calling postinst script where it restart service properly as well in the intended machine. But while exiting postinst script the restarted service getting killed. Any help on finding the reason and how to fix it?
Asked
Active
Viewed 315 times
0

Sathyanarayanan Ganesan
- 263
- 4
- 16
1 Answers
0
Am starting my service like sudo -u user_name java -server some_vm_options with jar of the package, configs > /dev/null &
.
I just changed it to sudo -u user_name nohup java -server some_vm_options with jar of the package, configs > /dev/null &
. Now my started service doesn't get killed.

Sathyanarayanan Ganesan
- 263
- 4
- 16
-
http://stackoverflow.com/questions/19233529/run-bash-script-as-daemon - The accepted answer in that thread is also one of the solutions. – Sathyanarayanan Ganesan Nov 22 '16 at 08:58
-
Would running the java process in a new thread and disowning it work ? – J V Dec 04 '16 at 20:05
-
@user3152463 Not even need to start in new thread. Just disown it. – Sathyanarayanan Ganesan Dec 05 '16 at 15:03