I have set up a server for deploying my rails app. I am not able to start unicorn service. It is giving me a failed status. I am totally new to this. So as per this tutorial https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04. I created the shared folders for the socket, PIDs on the server. but I am using mina for deployment after every release my shared folder which I manually created, disappears and goes away with the old release with my unicorn files. So I created that shared folders on my local Desktop but they are not getting pushed to the server via git. So where and how should I place my unicorn pids and sockets to make it working below are my files
my unicorn.rb file
root = "/home/deployer/apps/rails_app/current"
working_directory root
pid "#{root}/shared/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/shared/unicorn.railsapp.sock"
worker_processes 2
timeout 30
preload_app true
My /etc/init.d/unicorn_rails_app file
set -e
USAGE="Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
# app settings
USER="ggg"
APP_NAME="rails_app"
APP_ROOT="/home/$USER/$APP_NAME/current"
ENV="production"
# environment settings
PATH="/home/$USER/.rbenv/shims:/home/$USER/.rbenv/bin:$PATH"
CMD="cd $APP_ROOT && bundle exec unicorn -c config/unicorn.rb -E $ENV -D"
PID="$APP_ROOT/shared/pids/unicorn.pid"
OLD_PID="$PID.oldbin"
# make sure the app exists
cd $APP_ROOT || exit 1
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig () {
test -s $OLD_PID && kill -$1 `cat $OLD_PID`
}
case $1 in
start)
sig 0 && echo >&2 "Already running" && exit 0
echo "Starting $APP_NAME"
su - $USER -c "$CMD"
;;
stop)
echo "Stopping $APP_NAME"
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
echo "Force stopping $APP_NAME"
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload|upgrade)
sig USR2 && echo "reloaded $APP_NAME" && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
$CMD
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 $USAGE
exit 1
;;
esac
my mina deploy.rb file
require 'mina/bundler' require 'mina/rails' require 'mina/git' require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
set :domain, 'mydomain'
set :term_mode, :nil
set :deploy_to, 'path'
set :repository, 'myrepo'
set :branch, 'master'
set :user, 'gg' # Username in the server to SSH to.
set :keep_releases, 5
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log','tmp']
task :environment do
invoke :'rbenv:load'
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]
queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]
if repository
repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first
repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'
queue %[
if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
fi
]
end
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
end
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
to :launch do
queue "mkdir -p #{deploy_to}/current/tmp2/"
queue "touch #{deploy_to}/current/tmp2/restart.txt"
end
end
end
I am getting this errors
unicorn_rails_app.service - LSB: starts the unicorn app server Loaded: loaded (/etc/init.d/unicorn_rails_app; generated) Active: failed (Result: exit-code) since Tue 2019-06-04 07:35:52 UTC; 10s ago Docs: man:systemd-sysv-generator(8) Process: 30422 ExecStart=/etc/init.d/unicorn_rails_app start (code=exited, status=1/FAILURE)