mojohaus / appassembler

https://www.mojohaus.org/appassembler/
MIT License
93 stars 49 forks source link

JSW Daemon: Unable to resolve the full path of the configuration file #52

Open fgette-delfingen opened 7 years ago

fgette-delfingen commented 7 years ago

We use appassembler to generate a Java Daemon based on JSW. This daemon runs as a service in an Unix environment. We use traditional Sysvinit to configure this service. But when server reboots, the following error occurs: FATAL | wrapper | Unable to resolve the full path of the configuration file, /etc/conf/wrapper.conf: No such file or directory

I think this problem is caused by the fact we use multiple levels of soft link.

Our shell script (generated by the plugin) is named "myDaemon". Content of folder /etc/init.d: myDaemon -> ../../home/myApss/bin/myDaemon Content of folder /etc/rc2.d: (we start at runlevel 2): S20myDaemon -> ../init.d/myDaemon

The unix template of the plugin doesn't deal with multiple levels of soft link. See appassembler-maven-plugin/src/main/patches/sh.script.in As a workaround we use a modified version of this unix template. If you think my analyse is ok, I can create a pull request with our fixed unix template.

dantran commented 7 years ago

for user-specific customization, see http://www.mojohaus.org/appassembler/appassembler-maven-plugin/generate-daemons-mojo.html#unixScriptTemplate

fgette-delfingen commented 7 years ago

Thank you Dantran. We effectively use this configuration with our specific unix template. For those who might have the same problem, here is the fragment of shell that we use (we added the "while" statement):

...
# discover BASEDIR
BASEDIR=`dirname "$0"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
ls -l "$0" | grep -e '->' > /dev/null 2>&1
if [ $? = 0 ]; then
  #this is softlink
  _PWD=`pwd`
  _EXEDIR=`dirname "$0"`
  cd "$_EXEDIR"
  _BASENAME=`basename "$0"`
  _REALFILE=`ls -l "$_BASENAME" | sed 's/.*->\ //g'`
   while [ -h $_REALFILE ]; do
     _REALFILE=`ls -l "$_REALFILE" | sed 's/.*->\ //g'` 
   done
   BASEDIR=`dirname "$_REALFILE"`/..
   BASEDIR=`(cd "$BASEDIR"; pwd)`
   cd "$_PWD"
fi
...