Coder Social home page Coder Social logo

Comments (4)

tab avatar tab commented on June 11, 2024

Put config.ru file on root directory of your Rails project, example for Rails-4 application

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run Rails.application

from mina-unicorn.

jmccartie avatar jmccartie commented on June 11, 2024

@tab Thanks for getting back to me. I already have that in my config.ru file in the root of my app. I'm guessing Unicorn can't find it?

from mina-unicorn.

jmccartie avatar jmccartie commented on June 11, 2024

Got it.

Another tutorial had me setting my working_directory to /home/deployer/my_app ... it should have been /home/deployer/my_app/current

Thanks for your help!

from mina-unicorn.

tab avatar tab commented on June 11, 2024

@jmccartie, I'm glad to see you got it!

By the way you can use this unicorn.rb config file, it work with Rails-3 and Rails-4 applications.

# Set your full path to application.
app_dir = File.expand_path('../../', __FILE__)

# Set unicorn options
worker_processes 2
preload_app true
timeout 360

# Fill path to your app
working_directory app_dir

# Set up socket location
listen "#{app_dir}/tmp/sockets/unicorn.sock", :backlog => 64

# Loging
stderr_path "#{app_dir}/log/unicorn.stderr.log"
stdout_path "#{app_dir}/log/unicorn.stdout.log"

# Set master PID location
pid "#{app_dir}/tmp/pids/unicorn.pid"

before_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
  old_pid = "#{server.config[:pid]}.oldbin"
  if File.exists?(old_pid) && server.pid != old_pid
    begin
      sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
      Process.kill(sig, File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      # someone else did our job for us
    end
  end
end

after_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end

before_exec do |server|
  ENV['BUNDLE_GEMFILE'] = "#{app_dir}/Gemfile"
end

from mina-unicorn.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.