Simple question. How to start Rails using Foreman in test env?
RAILS_ENV=test bundle exec foreman start
// starts in develop
bundle exec foreman -e test start
// bombs
bundle exec foreman start -e test
// bombs
Foreman has to point to a Procfile, or Procfile has to exist in the current directory.
# Procfile
rails s
Then you'd run
foreman start -f Procfile
It's common practice to keep a Procfile.test, Procfile.dev, etc.
# Procfile.test
rails s -e test
Hope that helps :)
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
Is it possible run the rails foreman in production mode in local terminal?
Yes. Set the RAILS_ENV variable to production.
$ RAILS_ENV="production" foreman start
RAILS_ENV env value will be overridden by the .env file when foreman starts.
However, you can start foreman with --env option:
foreman start --env .env,production.env
# production.env
RAILS_ENV=production
RAILS_SERVE_STATIC_FILES=enabled
I am trying to install a RoR server on Amazon EC2 using Amazon Linux and Ansible. Everything goes through fine, at the end I am not able to run unicorn. I have checked that unicorn gem is installed
`gem list | grep unicorn`
showed unicorn installed.
When I type
`unicorn_rails`
I get command not found error. I checked my gem file and it has the line gem unicorn then I run bundle install and the output has unicorn in the list. Still not able to run it.
Thanks.
I'm not sure that you can run unicorn_rails. Just use:
bundle exec unicorn -p <port> -c <path_to_config_file>
For example:
bundle exec unicorn -p 3000 -c ./config/unicorn.rb
If you are using bundler run unicorn with bundle exec:
$ bundle exec unicorn_rails
Find out more here.
I'm using Foreman to run my Rails 4 application, and I'm getting duplicate output. Web shows pretty much the same info as Log.
Can I run foreman and just hide the Web output?
My procfile:
web: bundle exec passenger start -p $PORT --max-pool-size 3
log: tail -f ./log/development.log
The entries in your Procfile are just commands to run and you can tinker with them the same way you would on the command line.
So you could redirect all of the stdout for your web process to /dev/null (looks like you might be on a *nix system):
web: bundle exec passenger start -p $PORT --max-pool-size 3 > /dev/null
I add Gem 'unicorn' to Gemfile and call rails server unicorn -e production, but I get a load error. Then I add Gem 'unicorn_rails', then call rails server unicorn -e production, but I can't find the socket file. So I am considering if it doesn't use the config/unicorn.rb file as the configuration? So I call unicorn_rails -c config/unicorn.rb -E production -D, but I get another error text file busy.
So now I am stuck in this matter, could you help me? :)
It should be something looks like:
bundle exec unicorn -E production -c config/unicorn.rb
and you should only need unicorn gem
bundle exec unicorn -p $PORT -c ./config/unicorn.rb
works for me
I put it in the Procfile and then use Foreman to start it off by entering
foreman start
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
service unicorn_projectName start
works for me