无弹簧导轨 [英] Rails runner without spring

查看:45
本文介绍了无弹簧导轨的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ubuntu 设置上有 rails 4.2 + sidekiq,我每小时用 cron 开始我的工作

I have rails 4.2 + sidekiq on ubuntu setup and I'm starting my jobs with cron every hour with something like

bin/rails runner -e production 'MyJob.perform_later'

这基本上是采取一项工作并将数据放入redis,以便sidekiq可以接受并从那里开始.但是每次我这样做时,我都会在这个春季过程中卡住并等待某些事情(消耗内存)

This basically take a job and puts data to redis, so that sidekiq could take it and start from there. But everytime i do this I have this spring proccesses stuck and waiting for something (consuming memory)

ps aux | grep spring
root      Sl   07:13   0:00 spring server | myapp | started 6 secs ago
root      Ssl  07:13   0:03 spring app    | myapp | started 6 secs ago | production mode

有时我会看到其中的 10 个.有没有办法不启动spring server?

Sometimes I see like 10 of those. Is there any way not to start spring server?

谢谢.

推荐答案

发生这种情况是因为您正在使用 spring gem 并且您的 bin 文件夹已弹簧化".

This happens because you are using the spring gem and your bin folder has been "springified".

如果您查看 bin/rails 文件,您会看到 spring 已加载,然后继续运行您从中请求的任何内容.

If you take a look in the bin/rails file you will see that spring is loaded before moving on with running whatever you requested from it.

你可以通过运行un-springify"你的 bin 文件夹

You could "un-springify" your bin folder by running

bin/spring binstub --remove --all

这当然意味着您选择退出 Spring 为您提供的所有性能优势.这对于生产环境应该没问题.实际上,建议您不要在生产环境中安装 spring [1].

This would mean of course that you opt out from all performance benefits that spring provides you. This should be OK for production environments. In fact, it is recommended that you do not install spring in your production environments [1].

所以我建议你修改你的 Gemfile 并将 spring 放在 development 组下.在生产中,您通常会执行以下操作:

So I suggest that you modify your Gemfile and place spring under the development group. In production you usually do something like:

bundle install --without development test

那样 spring 将永远不会进入您的生产服务器.另请参阅 Github 上的此相关问题.

That way spring will never make it to your production servers. See also this related issue on Github.

--

1.Spring 项目自述文件

这篇关于无弹簧导轨的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆