I'm trying to start unicorn and I keep getting this error constantly.
My unicorn.rb (https://gist.github.com/anonymous/d1f3d9bcdd1a6c4d8435)
Command that I'm using to start unicorn:
/home/app/adsgold/# unicorn_rails master -c config/unicorn.rb -D -E production
Commands that I've already tried:
/home/app/adsgold/# unicorn_rails -c config/unicorn.rb -D -E production
/home/app/adsgold/# unicorn_rails master -c config/unicorn.rb -D -E production -p 3000
/home/app/adsgold/# bundle exec master unicorn -c unicorn.cnf -E production -D
Complete error beeing shown: https://gist.github.com/anonymous/828d9677f928fa671762
It looks you have RVM and Ruby installed system-wide. Generally it may cause lots of issues. Even RVM documentation warns about that. Try to install RVM and Ruby as user, which owns app directory. In that case you will get consistent system.
By the way, do you have this directory /home/deploy/apps/shared on your environment? Is it writable for your App? According Unicorn config following things depend on it:
pid "/home/deploy/apps/shared/pids/unicorn.pid"
stderr_path "/home/deploy/apps/shared/log/unicorn.stderr.log"
stdout_path "/home/deploy/apps/shared/log/unicorn.stdout.log"
If you do have all this stuff, content of /home/deploy/apps/shared/log/unicorn.stderr.log also would be helpful.
Are the necessary permissions in place? (I notice the read error comes from a globally-installed gem, so I'm wondering what all is where.)
Related
I added those rows to /home/web/.bash_profile. The web is the user of Rails app.
SECRET_KEY_BASE=xxxxxxxxxxxxxxxxxxxxx
export SECRET_KEY_BASE
I added this row into /etc/sudoers.
Defaults env_keep += "SECRET_KEY_BASE"
This command returns expected result.
sudo ruby -e 'puts ENV["SECRET_KEY_BASE"]'
If I run Unicorn without God, it can find SECRET_KEY_BASE from environment, and performs normally.
bundle exec unicorn_rails -c config/unicorn.rb -E production -D
Running Unicorn using sudo without God performs normally, too.
sudo bundle exec unicorn_rails -c config/unicorn.rb -E production -D
But when I run Unicorn with God using sudo, it failed to find SECRET_KEY_BASE and becomes error.
sudo god start my_app
The start command in the my_app.god is this.
God.watch do |w|
w.start = "cd #{rails_root} && bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D"
w.uid = 'web'
w.gid = 'web'
...
end
It seems that the problem exists around God rather than .bash_profile and Unicorn. Besides what should I try?
I added this line into the my_app.god
ENV["SECRET_KEY_BASE"] = 'xxxxxxxxxxxxxxxxxxxxxxxx'
I know that this isn't a cool solution, but it works. And SECRET_KEY_BASE isn't included in a Git repository as source code.
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
I have installed new ec2-instance for production server
when i tried the following command in the current folder
[ec2-user#ip-xx-xxx-xxx-xxx current]$ rvmsudo unicorn_rails -c config/unicorn/production.rb
-D --env production
sudo: unicorn_rails: command not found
Please let me know how to start the production server which is running at port 80.
Thanks in advance
For port 80: First run
export rvmsudo_secure_path=1
then
rvmsudo unicorn_rails -c config/unicorn/production.rb -D --env production
it will work for sure
You dont have to use rvmsudo and all to start your unicorn app server. You can do it
bundle exec unicorn -D -c /path/to/app/unicorn.rb -E production
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
I am running my rails application using ruby enterprise edition with unicorn as app server. I run this command
bundle exec unicorn -D -c /home/ubuntu/apps/st/config/unicorn.rb
I need to run this command soon after the system reboots or starts. I am running the app on ubuntu 10.04 LTS EC2 instance. I tried couple of examples which are mentioned on this site as well as this site but it’s not working for me. Any heads up
Try it as an Upstart. To do so, you need to create a myapp.conf file into the directory /etc/init/ with the contents below:
description "myapp server"
start on runlevel [23]
stop on shutdown
exec sudo -u myuser sh -c "cd /path/to/my/app && bundle exec unicorn -D -c /home/ubuntu/apps/st/config/unicorn.rb"
respawn
After that, you should be able to start/stop/restart your app with the commands below:
start myapp
stop myapp
restart myapp
Use ps -aux | grep myapp to check if your app is running.
You can use this file as a template, set appropriate paths mentioned in this file, make it executable and symlink into /etc/init.d/my_unicorn_server. Now you can start the server using:
sudo service my_unicorn_server start
Then you can do:
sudo update-rc.d my_unicorn_server defaults
To startup the unicorn server on system reboot automatically.
In my case, I just wanted it quick so I place the startup command in /etc/rc.local like below. Note that i'm using RVM.
# By default this script does nothing.
cd <your project dir>
/usr/local/rvm/gems/ruby-2.2.1/wrappers/bundle exec unicorn -c <your project dir>/config/unicorn.conf -D
test -e /etc/ssh/ssh_host_dsa_key || dpkg-reconfigure openssh-server
exit 0
Make sure your startup command is above the exit 0. After you reboot, check whether it is running or not by directly hitting the url of your application or use ps -aux | grep unicorn command.
Note* Previously I use Phusion Passenger but I'm having trouble to see its error log, so I move back to unicorn. I also tried #warantesbr without success, which I guess it fails because my whole environment where setup using root access.
If you are using unicorn_init script
You can configure a cron job to start the unicorn server on reboot
crontab -e
and add
#reboot /bin/bash -l -c 'service unicorn_<your service name> start >> /<path to log file>/cron.log 2>&1'