When I run foreman start on localhost all the process inside the Procfile run normally:
#Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
resque: env TERM_CHILD=1 QUEUE=* bundle exec rake resque:work
sqs_converted: bundle exec rake sqs:listen_converted
sqs_failed: bundle exec rake sqs:listen_failed
$ foreman start
13:52:07 sqs_failed.1 | started with pid 3521
13:52:07 web.1 | started with pid 3518
13:52:07 sqs_converted.1 | started with pid 3520
13:52:07 resque.1 | started with pid 3519
But when I deploy to heroku and run heroku ps all I have running is a web.1 instance
=== web: `bundle exec unicorn -p $PORT -c ./config/unicorn.rb`
web.1: up for 8m
Can't figure out what is happening...
Thanks
You still need to scale your processes with heroku ps:scale resque=1 sqs_convert=1 sqs_failed=1. You can read all about scaling your processes and the commands you can use in Scaling your process formation in the Heroku docs.
Related
Two years ago I was running the following command:
bundle exec puma -C config/puma.rb -b unix:/home/user/site/shared/tmp/sockets/user-puma.sock -d
bundle exec sidekiq -d
But now, after some Ubuntu updates, the -d flag is deprecated and I can't start the Puma and Sidekiq processes to run in background.
I also tried running:
bundle exec puma -C config/puma.rb -b unix:/home/user/site/shared/tmp/sockets/user-puma.sock &
bundle exec sidekiq &
This works only while I'm logged on the SSH, when I close the SSH connection, all processes opened with & are closed.
How can I run Puma, Sidekiq and other processes in background as Daemons?
What works for me is setting up my own systemd service for sidekiq
A well-documented example file is in the sidekiq github repository
Along with this, I'd also recommend using monit to watch background processes... here's a recipe from Lugo Labs that I loosely base my deploys off of
I try to run sidekiq service with supervisord
Here's my config:
[program:my-app-sidekiq-staging]
directory=/srv/www/DOMAIN/current
command=RAILS_ENV=production /usr/local/rvm/bin/rvm ruby-2.2.2#my-app-staging do bundle exec sidekiq -e production -d -C config/sidekiq.yml -L log/sidekiq.log
autostart=true
autorestart=true
redirect_stderr=true
After startup I’m have fatal error:
can't find command 'RAILS_ENV=production'
I’m confused, because my config for rails runs without errors
directory=/srv/www/DOMAIN/current
command=RAILS_ENV=production /usr/local/rvm/bin/rvm ruby-2.2.2#my-app-staging do bundle exec passenger start -S tmp/unicorn/ilp-app-unicorn.sock --environment production --friendly-error-pages
Your environment should not be set in the command but in a separate environment value.
environment=RAILS_ENV=production
See this question.
Supervisor and Environment Variables
In Ubuntu, I can run a rails server in the background as a daemon by passing in the --daemon option;
bundle exec puma -e production -b unix:///var/run/my_app.sock --daemon
However, how do I gracefully shut this daemonized process down? It's not a simple matter of crtl + c anymore :)
It is better to use puma control pumactl, it processes monitor and controller.
and then you can use it like this to stop
bundle exec pumactl -P /var/run/puma.pid stop
OR
pumactl -C unix://var/run/my_app_pumactl.sock [status|restart|halt|stop]
I have multiple workers, each of them seperated based on WorkerClass
Specified queues, concurrency etc. They are triggerin via cron jobs.
nohup bundle exec sidekiq -q worker1 -c 5 -e production
nohup bundle exec sidekiq -q worker2 -c 5 -e production
nohup bundle exec sidekiq -q worker3 -c 5 -e production
nohup bundle exec sidekiq -q worker4 -c 5 -e production
nohup bundle exec sidekiq -q worker5 -c 5 -e production
So, I need to start all of them on EC2 instance, and restart them after next deploy.
Can I use capistrano to do this? or any better way?
Thanks.
You should use something like God, upstart, or runit to keep your sidekiq processes up and running.
Using Foreman on my rails application with Ruby 1.9.3 just fine. Switched to JRuby and now, as an example, get :
18:22:16 solr.1 | /home/scott/.rvm/gems/jruby-1.6.8#jruby168-unicon/gems/foreman-0.47.0/bin/foreman-runner: 32: exec: bundle exec rake sunspot:solr:run: not found
When I run bundle exec rake sunspot:solr:run on its own on the command line it runs just fine
Procfile:
web: puma
solr: bundle exec rake sunspot:solr:run
redis: redis-server ./config/redis.conf
sidekiq: bundle exec sidekiq -c $SIDEKIQ_CONCURRENCY -q report -q publish_item -q audio -q import -q email -q enrollment -q bugsnag
bunchball: bundle exec sidekiq -c 2 -q bunchball
sidekiq_solr: bundle exec sidekiq -c 1 -q solr
You have install bundler in Jruby.
gem install bundler