1

我有一个 apache 骆驼路由,它使用 appassembler 将路由作为 linux(redhat) 服务运行。我创建了一个指向服务包装器的符号链接作为 /etc/init.d/daemon-science。当我尝试将符号链接作为服务运行时,它工作正常,但是当我重新启动时,它没有指向正确的文件夹。

wrapper.log 显示错误:致命 | 包装 | 2015/06/25 14:02:37 | 无法解析配置文件的完整路径,/etc/etc/wrapper.conf: No such file or directory

我的 pom.xml 有一个条目

    <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>  

不知何故,服务包装器的 BASEDIR 部分在重新启动期间获得了不同的路径:

# 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"

我可以手动更改 BASEDIR 的值,但是当我重新编译时,我需要再次手动更改 BASEDIR。

应该是 BEDIR ="${project.build.directory}/generated-resources/appassembler/jsw/daemon-science"

有没有办法修复错误?

提前致谢。

4

0 回答 0