Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

falcon output rack log policy is confusing when use on production with foreman like Procfile-based tools. #159

Closed
zw963 opened this issue Nov 25, 2021 · 1 comment

Comments

@zw963
Copy link

zw963 commented Nov 25, 2021

This issue similar as #90, but will more details and context, and explain why.

I am working on a personal app which use Roda + Sequel stack, i used puma for deploy, and switch to falcon for a while, it works, but, with some issue, see following detail.

I use Roda common_logger plugin for send log to a Logger.new($stdout), it works.

  LOGGER = Logger.new($stdout)
  LOGGER.level = Logger::WARN if ENV['RACK_ENV'] == 'production'
  plugin :common_logger, LOGGER

Please notice i set LOGGER.level to WARN on production.

it works quite well, when run bundle exec puma or bundle exec falcon serve --port 3000 directly from foreground, as a nginx backend, i can see expected http logs output to STDOUT.

Following is output from bundle exec falcon serve --port 3000.

image

Following is output from bundle exec puma, with following config.

image

Use following config for puma.

# config/puma/production.rb

threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads 1, threads_count
port ENV.fetch("PORT") { 3000 }
log_requests true

file = 'puma'
FileUtils.mkdir_p('tmp/pids')
pidfile "tmp/pids/#{file}.pid"
state_path "tmp/pids/#{file}.state"

FileUtils.mkdir_p('log')

workers Integer(ENV['WEB_CONCURRENCY'] || 2)

But when deploy on really production, i ran those server use a foreman like tools, it named procodile, i know it perhaps falcon not recommended be start like this way, but, anyway, because switch from puma just now, i still keep use old config, then, i meet the issue.

So, for debug purpose, i run procodile on foreground, like this: procodile start --foreground

When Procfile is puma

# Procofile
app: bundle exec puma

As you can see, i can see same log output as before.

image

Then, the issue is coming, when Procofile is falcon, like this:

# Procfile
app: bundle exec falcon serve --port 3000

I can not see any HTTP logs as before, it confusing ...

image

In fact, i guess falcon do two things

  1. output some JSON format Falcon::Adapters::Rack log, which is a little surprise.
  2. old HTTP log seem like missing, in fact, it is not, i just IO cached, and flush after wait several minute, anyway, a little wired.

For 1, it change log format unexpected (JSON format maybe useful, but if like user config it manually, is better)
For 2, raise exception (JSON format) immediately, but cache the log from STDOUT(http normal log), make this log not so useful.

Maybe what i thought on this issue is not correct, anyway, it should be more clear on why log behavior like this, i guess several issue
is relative to this too.

Thank you.

@travisbell
Copy link

travisbell commented Apr 26, 2024

Hey @zw963 in development, you can set CONSOLE_OUTPUT=Text which will keep the output as a human readable (non-JSON) format. I added it to my local .env file and never thought about it again.

In non development environments, JSON is nice to have so I don't fault the default when it doesn't detect an interactive terminal--FYI, through Foreman, that's what is happening.

@zw963 zw963 closed this as completed Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants