【问题标题】:Is there a way to be notified when a task started with nohup goes down?有没有办法在以 nohup 开始的任务失败时收到通知?
【发布时间】:2014-11-21 13:45:20
【问题描述】:

我在 DropWizard 中开发了一项服务。我使用这样的 nohup 命令在 AWS 服务器上运行 fat jar。

nohup java -jar myapp-0.0.1-SNAPSHOT.jar server my-configure.yml > outfile &

这很好用。

但是,昨天我尝试使用使用该服务的应用程序,但它无法正常工作。当我登录到服务器时,我意识到该服务不再运行。它已经运行了几个月,没有任何问题。在日志(输出文件)中,我只看到以下内容:

INFO  [2014-11-13 19:48:31,978] org.eclipse.jetty.server.Server: Graceful shutdown SocketConnector@0.0.0.0:9001
INFO  [2014-11-13 19:48:31,987] org.eclipse.jetty.server.Server: Graceful shutdown InstrumentedBlockingChannelConnector@0.0.0.0:9000
INFO  [2014-11-13 19:48:31,988] org.eclipse.jetty.server.Server: Graceful shutdown o.e.j.s.ServletContextHandler{/,null}
INFO  [2014-11-13 19:48:31,988] org.eclipse.jetty.server.Server: Graceful shutdown o.e.j.s.ServletContextHandler{/,null}

问题

  1. 如何解决服务停止运行的原因?...AWS 服务器是否已重新启动?
  2. 有没有更好的方法来做到这一点,并且不容易出现此类错误
  3. 有没有办法在服务停止运行时通知我...而不是每隔一段时间检查一次...

编辑

刚刚检查了 AWS 服务器上的正常运行时间,它显示为 7 天。这与服务中断的时间相吻合。我想解决方案是让服务在服务器重新启动时自动启动。

【问题讨论】:

    标签: java unix amazon-web-services dropwizard nohup


    【解决方案1】:

    您可以查看the solution used here,以便在程序关闭时给自己一个通知。 但是它不会知道它是用 nohup 调用的,这是 shell 的东西。但是一个 java 解决方案可能对你有用。

    根据您的编辑,您可能希望创建一个 init.d 脚本来启动(和停止)您的进程: can be found here 的模板。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-02
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多