I have an apache camel route that used appassembler to run the route as a linux(redhat)service. I created a symlink to the service wrapper as /etc/init.d/daemon-science. When I try to run the symlink as a service it is working fine but when I reboot it is not pointing in the right folder.
The wrapper.log shows an error: FATAL | wrapper | 2015/06/25 14:02:37 | Unable to resolve the full path of the configuration file, /etc/etc/wrapper.conf: No such file or directory
My pom.xml has an entry
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions>
<configuration>
<daemons>
<daemon>
<id>daemon-science</id>
<mainClass>org.apache.camel.spring.Main</mainClass>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>linux-x86-32</include>
<include>linux-x86-64</include>
<include>windows-x86-64</include>
</includes>
</generatorConfiguration>
</generatorConfigurations>
<platforms>
<platform>jsw</platform>
</platforms>
</daemon>
</daemons>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>echodir</id>
<goals>
<goal>run</goal>
</goals>
<phase>verify</phase>
<inherited>true</inherited>
<configuration>
<target>
<mkdir dir="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science/logs"/>
<chmod file="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science/bin/daemon-science" perm="755"/>
<chmod file="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science/bin/wrapper-linux-x86-64" perm="755"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
Somehow the BASEDIR part of service wrapper is getting a different path during reboot:
# 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'`
BASEDIR=`dirname "$_REALFILE"`/..
BASEDIR=`(cd "$BASEDIR"; pwd)`
cd "$_PWD"
fi
# Wrapper
WRAPPER_CMD="./wrapper"
WRAPPER_CONF="$BASEDIR/etc/wrapper.conf"
I can manually change the value of BASEDIR, but when I re-compile I need to manually change the BASEDIR again.
Should be BASEDIR ="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science"
Is there a way to fix the error?
Thanks in advance.