ubuntu - Tomcat:/etc/init.d/tomcat 不存在并且 monit 不工作

标签 ubuntu tomcat monit

我试图在 ubuntu 中使用 tomcat 构建 monit,但我遇到了两个问题。

我找不到 pid 文件,并且“/etc/init.d/tomcat”不存在

我该怎么做?

这是我在监视器中的代码:

check process tomcat with pidfile "/var/run/tomcat/tomcat.pid"
  start program = "/usr/local/tomcat/bin/startup.sh" as uid tomcat gid tomcat
  stop program = "/usr/local/tomcat/bin/shutdown.sh" as uid tomcat gid tomcat
  if failed port 8080 then alert
  if failed port 8080 for 5 cycles then restart

谢谢!

最佳答案

  1. 无论配置如何,Tomcat 似乎都不会创建 pid 文件。参见 this gist获取有关如何说服 Tomcat 创建一个的提示。
  2. 如果您使用的是 Ubuntu >= 15.04,您应该有 systemd(参见 this wiki entry)。因此,启动/停止应该是 systemctl start tomcatsystemctl stop tomcat(或 tomcat.service)。

如果你不能让你的 Tomcat 创建一个 pid 文件,你也可以使用 matching而不是 pidfile(但我总是推荐 pidfile!)。

其余的似乎没问题,但有一点限制:如果您开始使用 systemctl 来启动/停止服务,您需要有 super 用户权限才能这样做。您可以省略 start/stop programas uid tomcat gid tomcat 部分。


编辑 2019-11-02,14:00 UTC:

我的配置看起来像这样:

check process tomcat with pidfile "/var/run/tomcat/tomcat.pid"
  start program = "/bin/systemctl start tomcat.service"
  stop program = "/bin/systemctl stop tomcat.service"
  if failed port 8080 then restart
  if 3 restarts within 5 cycles then unmonitor

关于ubuntu - Tomcat:/etc/init.d/tomcat 不存在并且 monit 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58646808/

相关文章:

node.js - Monit 不启动 Node 脚本

监控 : reboot server on failed health check

ubuntu - 串行监视启动/重新启动进程

ubuntu - 如何从运行在 Java 11 上的 Jenkins 卸载 ruby​​-runtime 插件

spring - 如何使用eureka、zuul服务器在tomcat中部署不同的spring boot微服务?

java - Visual Studio Code Java 访问限制

java - 如何在 TomCat jdbc 池的帮助下杀死运行超过 1 秒的 sql 查询?

tomcat - Spring Boot - 忽略独立 Tomcat/外部 logback 文件

php - 检测文件从服务器中删除的原因

ubuntu - goLang 依赖项的问题