Use foreman. You define your processes in a Procfile
web: rails server
worker: bundle exec sidekiq
and run them with foreman start
.
Further reading:
Question
In the logging section of the web app manifesto "The Twelve Factor App", it suggests that each process send logs to STDOUT.
If I am doing Rails development locally with a process for the web server ("rails server") and a Sidekiq process for the background jobs ("bundle exec sidekiq"), I would like the logs to appear in a single stream, but I would still like to use STDOUT in my models, views, controllers, and Sidekiq workers.
Is there a way or a tool to be able to merge the two STDOUT streams together so that the logs are stored in a stream so that they can be viewed by tailing a single file?
Pas de solution correcte
Autres conseils
Use foreman. You define your processes in a Procfile
web: rails server
worker: bundle exec sidekiq
and run them with foreman start
.
Further reading:
It'll depend what OS you're running on I expect.
On a unix-like console you could run both processes in the background on a single console:
> rails server &
> bundle exec sidekiq &
That'll spit out stdout for both to the current console but you'll need to close them explicitly by pid, e.g. kill `pgrep -f rails`
Alternatively you can run each of them and append their output to a file which you can then tail (each of these in separate console windows):
> rails server >> combined_output.txt
> bundle exec sidekiq >> combined_output.txt
> tail -f combined_output.txt