V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
funky
V2EX  ›  Linux

tomcat systemd service in ubuntu

  •  
  •   funky · Jan 7, 2020 · 2754 views
    This topic created in 2310 days ago, the information mentioned may be changed or developed.
    在自定义 tomcat 成系统服务时候出现了问题,
    ```
    sudo service tomcat-ad status
    ● tomcat-ad.service - Ad Service
    Loaded: loaded (/etc/systemd/system/tomcat-ad.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2020-01-07 15:27:00 CST; 1s ago
    Process: 23931 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
    Process: 23991 ExecStart=/home/hadoop/ad-server/apache-tomcat-7.0.82/bin/startup.sh (code=exited, status=0/SUCCESS)
    Main PID: 24000 (java)
    Tasks: 28
    Memory: 375.8M
    CPU: 4.753s
    CGroup: /system.slice/tomcat-ad.service
    └─24000 /usr/java/jdk1.8.0_151/bin/java -Djava.util.logging.config.file=/home/hadoop/ad-server/apache-tomcat-7.0.82/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

    Jan 07 15:27:00 node3 systemd[1]: Starting Ad Service...
    Jan 07 15:27:00 node3 startup.sh[23991]: Tomcat started.
    Jan 07 15:27:00 node3 systemd[1]: Started Ad Service.
    ```
    status 查看是 active 但是我 stop 时候时候显示是 failed
    ```
    tomcat-ad.service - Ad Service
    Loaded: loaded (/etc/systemd/system/tomcat-ad.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Tue 2020-01-07 15:26:48 CST; 3s ago
    Process: 23931 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
    Process: 23826 ExecStart=/home/hadoop/ad-server/apache-tomcat-7.0.82/bin/startup.sh (code=exited, status=0/SUCCESS)
    Main PID: 23835 (code=exited, status=143)

    Jan 07 15:25:59 node3 systemd[1]: Starting Ad Service...
    Jan 07 15:25:59 node3 startup.sh[23826]: Tomcat started.
    Jan 07 15:25:59 node3 systemd[1]: Started Ad Service.
    Jan 07 15:26:47 node3 systemd[1]: Stopping Ad Service...
    Jan 07 15:26:48 node3 systemd[1]: tomcat-ad.service: Main process exited, code=exited, status=143/n/a
    Jan 07 15:26:48 node3 systemd[1]: Stopped Ad Service.
    Jan 07 15:26:48 node3 systemd[1]: tomcat-ad.service: Unit entered failed state.
    Jan 07 15:26:48 node3 systemd[1]: tomcat-ad.service: Failed with result 'exit-code'.
    ```
    为什么是 return status 143 呢?
    3 replies    2020-01-07 16:24:19 +08:00
    funky
        1
    funky  
    OP
       Jan 7, 2020
    顺便贴上 服务脚本是怎么写的
    ```
    [Unit]
    Description=Ad Service

    [Service]
    Type=forking
    PIDFile=/home/hadoop/ad-server/apache-tomcat-7.0.82/bin/catalina.pid
    Restart=on-failure
    WorkingDirectory=/home/hadoop/ad-server/apache-tomcat-7.0.82/
    ExecStart=/home/hadoop/ad-server/apache-tomcat-7.0.82/bin/startup.sh
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target

    ```
    funky
        2
    funky  
    OP
       Jan 7, 2020
    tomcat 开启了 jmx
    funky
        3
    funky  
    OP
       Jan 7, 2020
    将 SuccessExitStatus=143 添加上 就可以,结贴
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5695 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 07:39 · PVG 15:39 · LAX 00:39 · JFK 03:39
    ♥ Do have faith in what you're doing.