【问题标题】:.ebextensions file ignored when trying to run rescue via elastic beanstalk尝试通过弹性 beantalk 运行救援时忽略 .ebextensions 文件
【发布时间】:2016-04-23 05:38:06
【问题描述】:

我有一个使用救援的 Rails 应用程序。该应用程序使用弹性 beanstalk(运行 Ruby 2.1(Passenger Standalone)的 64 位 Amazon Linux 2015.09 v2.0.6)部署,我正在尝试使用 monit 运行救援。经过一些研究 .ebextensions 似乎是要走的路。但是,看起来好像文件被忽略了。我没有看到我用来调试正在编写的东西的文件(/var/app/current/tmp/success),没有安装monit,也没有创建monit配置文件。

我的应用 .ebextensions 99run.config

这是99run.config的内容

包: 百胜: 监控:[] 文件: “/etc/monit.d/resque_worker”: 模式:“000644” 所有者:根 组:根 内容:| 检查进程 resque_worker_QUEUE 使用 pidfile /var/app/current/tmp/resque_worker_QUEUE.pid start program = "/bin/sh -l -c 'cd /var/app/current; nohup rake environment resque:work QUEUE=* VERBOSE=1 PIDFILE=/var/app/current/tmp/resque_worker_QUEUE.pid >> / var/app/current/log/resque_worker_QUEUE.log 2>&1'" 作为 uid webapp 和 gid webapp 停止程序 = "/bin/sh -c 'cd /var/app/current && kill -9 $(cat /var/app/current/tmp/resque_worker_QUEUE.pid) && rm -f /var/app/current/tmp /resque_worker_QUEUE.pid;退出 0;'" 如果 totalmem 在 10 个周期内大于 300 MB 然后重新启动 # 吃掉内存? 组 resque_workers 命令: 测试命令: 命令:回显“ebextensions 运行”> /var/app/current/tmp/success 服务: 系统启动: 监控: 确保运行:真 启用:真

【问题讨论】:

    标签: ruby-on-rails amazon-elastic-beanstalk


    【解决方案1】:

    您非常接近 - 我成功地使用了非常相似的结构。 (我想我们都是从同一篇博文开始的……)不过有几个 cmets:

    您的test_command 没有产生您想要的结果,因为success 文件正在被覆盖。每the documentation

    您可以使用 commands 键在 EC2 实例上执行命令。这些命令按名称的字母顺序处理,它们在设置应用程序和 Web 服务器以及提取应用程序版本文件之前运行。

    发生的情况是 success 正在写入 /var/app/current/tmp,而您的应用程序正在部署到 /var/app/ondeck。后来/var/app/current被删除,/var/app/ondeck重命名为/var/app/current,消除了success文件。

    接下来,这块有错别字:

    service:
      sysvinit:
        monit:
    

    应该改为services

    services:
      sysvinit:
        monit:
    

    最后,我必须通过将以下内容添加到 files 部分来告诉 monit 在每次部署期间明确启动和停止 resque:

    "/opt/elasticbeanstalk/hooks/appdeploy/post/98_start_resque.sh":
      mode: "000755"
      owner: root
      group: root
      content: |
        #!/usr/bin/env bash
    
        su -s /bin/bash -c "monit start resque_worker_QUEUE"
    

    还有以下commands

    commands:
      01_remove_worker_bak:
        command: "rm /etc/monit.d/resque_worker_QUEUE.bak"
        ignoreErrors: true
      02_stop_worker:
        command: "monit stop resque_worker_QUEUE"
        ignoreErrors: true
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      • 2022-01-13
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      相关资源
      最近更新 更多