Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在生产环境中部署ruby beaneater后台处理的最佳方法_Ruby On Rails_Deployment_Background Process_Production_Beanstalkd - Fatal编程技术网

Ruby on rails 在生产环境中部署ruby beaneater后台处理的最佳方法

Ruby on rails 在生产环境中部署ruby beaneater后台处理的最佳方法,ruby-on-rails,deployment,background-process,production,beanstalkd,Ruby On Rails,Deployment,Background Process,Production,Beanstalkd,我一直在我的RoR应用程序中使用beaneater进行后台处理。我正在使用upstart从我的upstart srcipt运行rake任务,从而在后台运行beaneter exec bundle exec rake RAILS_ENV=production bs:beaneater 我的任务是 task beaneater: :environment do @beanstalk = BackgroundWorker.get_beanstalkd asynch_tasks =

我一直在我的RoR应用程序中使用beaneater进行后台处理。我正在使用upstart从我的upstart srcipt运行rake任务,从而在后台运行beaneter

exec bundle exec rake RAILS_ENV=production bs:beaneater
我的任务是

  task beaneater: :environment do
    @beanstalk = BackgroundWorker.get_beanstalkd
    asynch_tasks = BackgroundWorker.descendants
    asynch_tasks.each do |aClass|
      @beanstalk.jobs.register(aClass.tube_name) do |job|
        aClass.process(job)
      end
    end
    @beanstalk.jobs.process!
  end
通过这种方式,我可以运行尽可能多的后台进程,但

  • 如果需要,我无法自动生成新进程
  • rake任务从upstart kills运行,在将任务掩埋在 发生错误的情况
  • 一个管理员界面来查看详细信息将是一个很好的选择

  • 关于如何在生产环境中部署beaneater的任何建议。

    因为提到了
    upstart
    ——您必须运行某种裸机或虚拟服务器。因此,您的服务器容量有限,几乎没有理由进行自动扩展。对于您的服务器来说,有一些确切数量的进程是最佳的—您不能超过这些进程,因为会有稳定性和性能问题,没有理由低于这些进程

    至于重新启动失败的进程,请确保您已配置
    respawn

    对于更高级的选项,您可以使用在许多现代Linux中作为标准配置的
    systemd

    /etc/systemd/system/yourservice@.service
    (注意文件名中的
    @
    ,用于缩放):

    设置为在启动时启动并运行:

    systemctl后台程序重新加载
    systemctl启用您的服务@{1..5}.service
    systemctl启动您的服务@{1..5}.service
    
    对于资源监控,您可以使用所有这些进程制作一个单独的“切片”,并查看
    systemd cgtop
    中的总结,包括cpu/内存/网络io等


    如果你真的需要自动缩放-你的路径是云托管,docker和kubernetes登陆,但这要复杂得多(和/或昂贵,取决于提供商)。

    因为提到了upstart,你必须运行某种裸机或虚拟服务器。因此,您的服务器容量有限,几乎没有理由进行自动扩展。对于您的服务器来说,有一些确切数量的进程是最佳的—您不能超过这些进程,因为会有稳定性和性能问题,没有理由低于这些进程

    至于重新启动失败的进程,请确保您已配置
    respawn

    对于更高级的选项,您可以使用在许多现代Linux中作为标准配置的
    systemd

    /etc/systemd/system/yourservice@.service
    (注意文件名中的
    @
    ,用于缩放):

    设置为在启动时启动并运行:

    systemctl后台程序重新加载
    systemctl启用您的服务@{1..5}.service
    systemctl启动您的服务@{1..5}.service
    
    对于资源监控,您可以使用所有这些进程制作一个单独的“切片”,并查看
    systemd cgtop
    中的总结,包括cpu/内存/网络io等

    如果您真的需要自动缩放-您的路径是云托管,docker和kubernetes会登陆,但它要复杂得多(和/或昂贵,取决于提供商)

    [Service]
    ExecStart=bundle exec rake bs:beaneater
    Restart=on-failure
    WorkingDirectory=/your/deploy/path
    Environment='RAILS_ENV=production'
    
    [Install]
    WantedBy=multi-user.target