Wednesday, 6 June 2018

Unix setup in rails application

Unicorn setup for deployment

1. gem 'unicorn' add in gem file

2. create config/unicorn.rb file

3. paste this file
# set path to application
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
working_directory app_dir


# Set unicorn options
worker_processes 2
preload_app true
timeout 30

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

# Logging
stderr_path "#{shared_dir}/log/unicorn.stderr.log"
stdout_path "#{shared_dir}/log/unicorn.stdout.log"

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

4. mkdir -p shared/pids shared/sockets shared/log

5. create script in /etc/init.d/unicorn_appname

6. sudo chmod 755 /etc/init.d/unicorn_appname

7. sudo update-rc.d unicorn_appname defaults

8. sudo service unicorn_appname start

No comments:

Post a Comment

Interactor in Rails

What is interactor? Interactor provides a common interface for performing complex user interactions An interactor is a simple, sin...