mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
DEV: Use existing loggers for stuff we log in config/unicorn.conf.rb
(#27237)
This commit updates various spots in `config/unicorn.conf.rb` which were doing `STDERR.puts` to either use `server.logger` which is unicorn's logger or `Rails.logger` which is Rails' logger. The reason we want to do so is because `STDERR.puts` doesn't format the logs properly and is a problem especially when custom loggers with structured formatting is enabled.
This commit is contained in:
parent
3a2319be2b
commit
47523fa57c
@ -71,7 +71,7 @@ before_fork do |server, worker|
|
|||||||
Thread.new do
|
Thread.new do
|
||||||
while true
|
while true
|
||||||
unless File.exist?("/proc/#{supervisor}")
|
unless File.exist?("/proc/#{supervisor}")
|
||||||
puts "Kill self supervisor is gone"
|
server.logger.error "Kill self supervisor is gone"
|
||||||
Process.kill "TERM", Process.pid
|
Process.kill "TERM", Process.pid
|
||||||
end
|
end
|
||||||
sleep 2
|
sleep 2
|
||||||
@ -165,11 +165,11 @@ before_fork do |server, worker|
|
|||||||
"Sidekiq is consuming too much memory (using: %0.2fM) for '%s', restarting" %
|
"Sidekiq is consuming too much memory (using: %0.2fM) for '%s', restarting" %
|
||||||
[(sidekiq_rss.to_f / 1.megabyte), ENV["DISCOURSE_HOSTNAME"]],
|
[(sidekiq_rss.to_f / 1.megabyte), ENV["DISCOURSE_HOSTNAME"]],
|
||||||
)
|
)
|
||||||
|
|
||||||
restart = true
|
restart = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if last_heartbeat < Time.now.to_i - @sidekiq_heartbeat_interval
|
if last_heartbeat < Time.now.to_i - @sidekiq_heartbeat_interval
|
||||||
STDERR.puts "Sidekiq heartbeat test failed, restarting"
|
|
||||||
Rails.logger.warn "Sidekiq heartbeat test failed, restarting"
|
Rails.logger.warn "Sidekiq heartbeat test failed, restarting"
|
||||||
|
|
||||||
restart = true
|
restart = true
|
||||||
@ -218,19 +218,21 @@ before_fork do |server, worker|
|
|||||||
last_heartbeat_ago =
|
last_heartbeat_ago =
|
||||||
Time.now.to_i - Discourse.redis.get(Demon::EmailSync::HEARTBEAT_KEY).to_i
|
Time.now.to_i - Discourse.redis.get(Demon::EmailSync::HEARTBEAT_KEY).to_i
|
||||||
if last_heartbeat_ago > Demon::EmailSync::HEARTBEAT_INTERVAL.to_i
|
if last_heartbeat_ago > Demon::EmailSync::HEARTBEAT_INTERVAL.to_i
|
||||||
STDERR.puts(
|
Rails.logger.warn(
|
||||||
"EmailSync heartbeat test failed (last heartbeat was #{last_heartbeat_ago}s ago), restarting",
|
"EmailSync heartbeat test failed (last heartbeat was #{last_heartbeat_ago}s ago), restarting",
|
||||||
)
|
)
|
||||||
|
|
||||||
restart = true
|
restart = true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Restart process if memory usage is too high
|
# Restart process if memory usage is too high
|
||||||
email_sync_rss = max_email_sync_rss
|
email_sync_rss = max_email_sync_rss
|
||||||
if email_sync_rss > max_allowed_email_sync_rss
|
if email_sync_rss > max_allowed_email_sync_rss
|
||||||
STDERR.puts(
|
Rails.logger.warn(
|
||||||
"EmailSync is consuming too much memory (using: %0.2fM) for '%s', restarting" %
|
"EmailSync is consuming too much memory (using: %0.2fM) for '%s', restarting" %
|
||||||
[(email_sync_rss.to_f / 1.megabyte), ENV["DISCOURSE_HOSTNAME"]],
|
[(email_sync_rss.to_f / 1.megabyte), ENV["DISCOURSE_HOSTNAME"]],
|
||||||
)
|
)
|
||||||
|
|
||||||
restart = true
|
restart = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user