Why Does Foreman Not Output Some Things Until I Press Control-C

Unable to run rails commands due to invalid URI

It turns out that this was a problem with ElasticSearch. The ElasticSearch_URL environment variable was not set, and that led to an invalid URI.

This problem was identified by the numbers ":9200" in the URL, which is the default port that ElasticSearch uses.

Rails: how to debug localhost not responding with delayed_job / foreman

This is only a partial answer, but it might help you with debugging.

Rails buffers logging by default, and flushes it after every web request. One option is to simply replace the logger with a simpler logger

Rails.logger = Logger.new(STDOUT)

You can also configure the buffered logger to flush more often

Rails.logger.auto_flushing = (Rails.env.development? || Rails.env.test?)

You also have to be careful about STDOUT. In my current project I have stdout flushing enabled in both config.ru and my background bootup (I'm using sidekiq, so the boot process may be a little different)

STDOUT.sync = true

As to your larger problem,

I'm surprised that the rails process is running background tasks. Is there an option to disable that, at least for experimentation?

Then there are the standard debugging tools - all the database calls on save worry me, so I'd try various combinations of disabling them to see if anything improves. Especially with two of them - for instance, if your before_save hook changes a value in the model, it might be trigger a validation; if that resets the before_save hooks, you'd have a loop.

foreman only shows line with “started with pid #” and nothing else

I’ve been able to resolve this issue by 2 different ways:

  1. From https://github.com/ddollar/foreman/wiki/Missing-Output:

    If you are not seeing any output from your program, there is a likely
    chance that it is buffering stdout. Ruby buffers stdout by default. To
    disable this behavior, add this code as early as possible in your
    program:

    # ruby
    $stdout.sync = true
  2. By installing foreman via the heroku toolbelt package

But I still don’t know what’s happening nor why this 2 ways above resolved the issue…



Related Topics



Leave a reply



Submit