- 
                Notifications
    
You must be signed in to change notification settings  - Fork 41.6k
 
Description
I had a look to other issues and the problem seems new.
Here is what I have in my setup:
- an application deployed in 
/opt/myappwith the jar in/opt/myapp/myapp-X.Y.Z-R.jar - an init.d script defined like this (created to read the /etc/default/myapp file):
 
#!/bin/bash
NAME=myapp
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
MYAPP_JAR=`find /opt/myapp/lib/ -name \\*\\.jar`
${MYAPP_JAR} $@
- the jar belongs to 
myappuser - the 
/etc/default/myappfiles contains a few APP specific env variables and also setsJAVA_HOME,MODE=service, server host, port and context path (not relevant for this ticket). 
Now this is what happens
In that case and when reading the init script inside the jar (identified as being this one: https://github.com/spring-projects/spring-boot/blob/9e8beb7323215f5de0aaa778699fe70717604f39/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script)
- L28: 
JARFILEis not set so not settingjarFile - L29: 
APP_NAMEis not defined so not settingidentity - L33: since 
jarFileis still emtpy, we set it to/opt/myapp/myapp-X.Y.Z-R.jar - L34: JAR file exists but is not a symbolic link, so we do not enter the loop and do not set 
init_script - L53: 
PID_FOLDERnorpidFolderare previously defined, soPID_FOLERis set to/var/run - L55: 
/var/runexists and is executable so nothing changed - L63: 
identityis still empty so we enter the block - L64: 
init_scriptis an empty string, so we jump to the else block - L67: we set 
identitytomyapp-X.Y.Z-R_optmyapplib - L111: 
init_scriptandAPP_NAMEare still empty strings not equal toidentity, so we do no enter the block - L114: we set 
pid_fileto/var/run/myapp-X.Y.Z-R_optmyapplib.pid - L150: when trying to start the app, we do a 
chown myappuser /var/run 
And this is where it gets broken: other services then cannot write their PID inside /var/run because owner has changed (from root to myappuser) and dir mode is 755 so user from root group cannot write there
There is an easy workaround: set the APP_NAME variable and then it will all be fixed for us. But since others may have the same issue, I think something has to be done (maybe ensure that we do not change permissions if PID_FOLDER ends up being /var/run or maybe simply remove the if on L111)