Reputation: 642
I've been messing around supervisor logfile capabilities. The program writes to stdout:
ruby sample.rb
>>0.9668821900023237 [tps]
>>61.91346356232367 [tps]
>>Heartbeat....
>>58.84168122263758 [tps]
>>Heartbeat....
When I run it from supervisor, I've got log files created, but stdout_logfile
is always empty. When I mess something in sample.rb
, so that I have any kind of exception, it is successfully written to stdout_logfile
due to redirect_stderr
.
Supervisor configuration file:
[program:sample]
priority=50
command=/usr/bin/ruby sample.rb
numprocs=1
directory=/home/myapp/myapp
autorestart=true
autostart=true
startsecs=10
stopwaitsecs=90
redirect_stderr=true
stdout_logfile=/var/log/sample.out.log
user=myapp
Why I see no output on stdout_logfile
?
Upvotes: 1
Views: 3565
Reputation: 642
This issue is solved by simply calling flush
on stdout.
puts "hello world"
$stdout.flush
Related: Problem redirecting stdout in Ruby script
Upvotes: 1