【问题标题】:How to run delayed_jobs in production environment如何在生产环境中运行delayed_jobs
【发布时间】:2020-02-12 03:17:36
【问题描述】:

我在rails应用程序开发中使用delayed_job,在开发环境中我使用bin/delayed_job start

但是在生产环境中怎么做呢?

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 delayed-job


    【解决方案1】:
    RAILS_ENV=production bin/delayed_job start
    

    这应该使延迟的作业在生产环境中运行

    【讨论】:

    • 我真的被困在这里了......谢谢......一个快速的解决方案
    • 这给了我权限错误 - -bash: bin/delayed_job: Permission denied。使用 Centos 进行生产。有什么建议吗?
    • 调用这个时你在rails项目目录吗?
    【解决方案2】:

    开始:

    cd /home/user/app;
    bundle exec /usr/bin/env RAILS_ENV=production /home/user/app/script/delayed_job start
    

    停止:

    cd /home/user/app; 
    bundle exec /usr/bin/env RAILS_ENV=production /home/user/app/script/delayed_job stop
    

    请参阅github 的官方文档。

    RAILS_ENV=production script/delayed_job start
    RAILS_ENV=production script/delayed_job stop
    
    # Runs two workers in separate processes.
    RAILS_ENV=production script/delayed_job -n 2 start
    RAILS_ENV=production script/delayed_job stop
    
    # Set the --queue or --queues option to work from a particular queue.
    RAILS_ENV=production script/delayed_job --queue=tracking start
    RAILS_ENV=production script/delayed_job --queues=mailers,tasks start
    
    # Use the --pool option to specify a worker pool. You can use this option multiple times to start different numbers of workers for different queues.
    # The following command will start 1 worker for the tracking queue,
    # 2 workers for the mailers and tasks queues, and 2 workers for any jobs:
    RAILS_ENV=production script/delayed_job --pool=tracking --pool=mailers,tasks:2 --pool=*:2 start
    
    # Runs all available jobs and then exits
    RAILS_ENV=production script/delayed_job start --exit-on-complete
    # or to run in the foreground
    RAILS_ENV=production script/delayed_job run --exit-on-complete
    

    【讨论】:

      【解决方案3】:

      如果其他人遇到 -bash: bin/delayed_job: Permission denied 错误,就像 Disha 在上面的 cmets 中所做的那样,对于 Centos 来说,将项目目录中 bin/ 文件夹中的延迟作业设置为可执行文件就足够了。

      【讨论】:

        猜你喜欢
        • 2019-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-12
        • 2020-07-28
        • 1970-01-01
        • 2012-12-26
        • 2011-03-20
        相关资源
        最近更新 更多