V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
funky
V2EX  ›  Linux

tomcat systemd service in ubuntu

  •  
  •   funky · 2020-01-07 15:40:28 +08:00 · 2223 次点击
    这是一个创建于 1569 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在自定义 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 条回复    2020-01-07 16:24:19 +08:00
    funky
        1
    funky  
    OP
       2020-01-07 15:41:44 +08:00
    顺便贴上 服务脚本是怎么写的
    ```
    [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
       2020-01-07 16:09:54 +08:00
    tomcat 开启了 jmx
    funky
        3
    funky  
    OP
       2020-01-07 16:24:19 +08:00
    将 SuccessExitStatus=143 添加上 就可以,结贴
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3128 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:59 · PVG 22:59 · LAX 07:59 · JFK 10:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.