微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 CentOS 上安装时,Spring Boot 服务 RPM 返回 code=exited status=203/EXEC

如何解决在 CentOS 上安装时,Spring Boot 服务 RPM 返回 code=exited status=203/EXEC

我准备了一个要安装在 CentOS 上的 RPM 包。好像安装成功了。但是我无法启动它 - 它会引发 203 错误Process: 4574 ExecStart=/opt/vcs/cegp/dtm/my_service/my_service.jar (code=exited,status=203/EXEC)

父 pom 在 <build><pluginManagement> 中有一个 rpm 插件

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>rpm-maven-plugin</artifactId>
    <version>${plugin-rpm-maven.version}</version>
    </plugin>

它还具有复制所需资源的资源插件。所有这些似乎最终都会出现在我需要它们的地方。 实际代码和所有东西都放在子模块中,子模块包含所有依赖项、程序集插件等以及这个 rpm 插件

<profile><id>rpm</id>
   <build>
<pluginManagement>
  <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>${plugin-rpm-maven.version}</version>
<executions>
<execution>
 <id>generate-rpm</id>
     <phase>install</phase> 
      <goals>
         <goal>rpm</goal>
  </goals>
 </execution>
</executions>
<configuration>
<license>...</license>
<version>${project.version}</version>
<group>Applications/System</group>
<name>${artifact-id}</name>
<defaultUsername>${rpm.username}</defaultUsername>
<defaultGroupname>${rpm.groupname}</defaultGroupname>
<vendor>...</vendor>
<distribution>rhel8</distribution>
<defaultDirmode>755</defaultDirmode>
<defaultFilemode>755</defaultFilemode>

<mappings>
<mapping>
  <directory>${rpm.service.file.directory}</directory>
   <directoryIncluded>false</directoryIncluded>
    <filemode>555</filemode>
    <username>root</username>
         <groupname>root</groupname>
           <sources>
               <source>
                <destination>my_service.service</destination>
                <location>
                    target/scripts/rpm/etc/systemd/system/my_service.service
                </location>
            </source>
        </sources>
    </mapping>
    <mapping>
        <directory>${rpm.install.directory}</directory>
        <filemode>550</filemode>
        <sources>
            <source>
                <location>${main.basedir}/SERVICE_HOME</location>
            </source>
        </sources>
    </mapping>

    <mapping>
        <directory>${rpm.install.directory}</directory>
        <filemode>777</filemode>
        <sources>
            <source>
                <destination>${artifact-id}.jar</destination>
                <location>${project.build.directory}/MyService.jar</location>
            </source>
        </sources>
    </mapping>


</mappings>
<preinstallScriptlet>
    <scriptFile>${main.basedir}/src/main/scripts/rpm/preInstall.sh</scriptFile>
</preinstallScriptlet>
<postinstallScriptlet>
    <scriptFile>${main.basedir}/src/main/scripts/rpm/postInstall.sh</scriptFile>
</postinstallScriptlet>
<preremoveScriptlet>
    <scriptFile>${main.basedir}/src/main/scripts/rpm/preRemove.sh</scriptFile>
</preremoveScriptlet>
</configuration>
</plugin>

这是 my_service.service 文件

[Unit]
Description=Event Consumer
After=syslog.target

[Service]
Type=simple
Restart=always
RestartSec=5
User=vcs_pbl
ExecStart=/opt/vcs/cegp/dtm/my_service/my_service.jar
WorkingDirectory=/opt/vcs/cegp/dtm/my_service/
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

正如我所说,这确实生成一个 RPM(Jenkins、RedHat),我可以在 CentOS 8 上安装它,但它无法启动。我在此处和 Linux 分支上阅读了大量有关此错误的其他答案,但没有一个我有帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。