How do I get unicorn to work with my contact form?

February 22, 2014 2.3k views
I am using the Ruby on Rails on Ubuntu (nginx and unicorn) application image for my server. I configured unicorn and nginx to load my app and everything seemed to be working. Then I tried to use the contact form on my site and it appeared to work but nothing went through (it also completed too fast). My first question is where can I find webrick like logs for my unicorn server? I looked at /home/unicorn/log/unicorn.log but that doesn't have the information I need. On reboot this is what the unicorn process looks like: rails@edawebdesign:~$ ps -e f | grep unicorn 1179 pts/1 S+ 0:00 \_ grep unicorn 779 ? Sl 0:00 unicorn master -D -c /home/unicorn/unicorn.conf -E production 782 ? Sl 0:02 \_ unicorn worker[0] -D -c /home/unicorn/unicorn.conf -E production 784 ? Sl 0:02 \_ unicorn worker[1] -D -c /home/unicorn/unicorn.conf -E production This is the only way I can get my contact form to work: 1. sudo kill the master and worker processes 2. go to the root of my app and run unicorn_rails &: rails@edawebdesign:~/apps/edawebdesign/current$ unicorn_rails & [1] 1243 rails@edawebdesign:~/apps/edawebdesign/current$ I, [2014-02-22T19:59:19.695911 #1243] INFO -- : listening on addr=0.0.0.0:8080 fd=9 I, [2014-02-22T19:59:19.696312 #1243] INFO -- : worker=0 spawning... I, [2014-02-22T19:59:19.697360 #1243] INFO -- : master process ready I, [2014-02-22T19:59:19.698812 #1245] INFO -- : worker=0 spawned pid=1245 I, [2014-02-22T19:59:19.699163 #1245] INFO -- : Refreshing Gem list I, [2014-02-22T19:59:21.426114 #1245] INFO -- : worker=0 ready Then I get a slightly different looking unicorn process list: rails@edawebdesign:~/apps/edawebdesign/current$ ps -e f | grep unicorn 1243 pts/1 Sl 0:00 \_ unicorn_rails master -l0.0.0.0:8080 1245 pts/1 Sl 0:01 | \_ unicorn_rails worker[0] -l0.0.0.0:8080 1266 pts/1 S+ 0:00 \_ grep unicorn This results in my app working as expected. Anyone have an idea of what is going on here?
4 Answers
Does /home/unicorn/unicorn.conf state where the log files are stored? What mail server is your app configured to use?
This is my unicorn.conf:

`isten "127.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "/home/rails/apps/edawebdesign/current"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"`

and this is the end of my /config/environments/production.rb:

`isten "127.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "/home/rails/apps/edawebdesign/current"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"`
edit: this is the end of my production.rb:

config.log_formatter = ::Logger::Formatter.new

config.assets.debug = true
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["DOMAIN_NAME"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => ENV["DOMAIN_NAME"] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = true
Check /home/unicorn/log/unicorn.log for info on why it's failing to send emails. Are there any errors in there?
Have another answer? Share your knowledge.