ruby on rails - Syntax error near unexpected token `(' on service unicorn start on amazon EC2 linux -


i trying setup unicorn in amazon ec2. following this blog.

but when start unicorn using:

sudo service unicorn_firstapp start 

i getting following error:

/home/ec2-user/rails_projects/firstapp/config/unicorn.rb: line 2: syntax error near unexpected token `(' /home/ec2-user/rails_projects/firstapp/config/unicorn.rb: line 2: `app_dir = file.expand_path("../..", __file__)' 

what mistake? if 1 has idea issue, please share me.

unicorn.rb:

# set path 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 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" 

/etc/init.d/unicorn_firstapp:

#!/bin/sh  ### begin init info # provides:          unicorn # required-start:    $all # required-stop:     $all # default-start:     2 3 4 5 # default-stop:      0 1 6 # short-description: starts unicorn app server # description:       starts unicorn using start-stop-daemon ### end init info  set -e   usage="usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"  # app settings user="ec2-user" app_name="firstapp" app_root="/home/$user/rails_projects/$app_name" 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"  #setting rvm rails_env=production pid=$app_root/shared/pids/unicorn.pid desc="unicorn app - $rails_env" unicorn="$app_root/config/unicorn.rb" unicorn_opts="-c $app_root/config/unicorn.rb -e $rails_env -d" cmd="rails_env=$rails_env $unicorn $unicorn_opts" timeout=60   # make sure 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 

try including correct hash-bang header, otherwise code executed using shell:

#!/usr/bin/env ruby  app_dir = file.expand_path("../..", __file__) ... 

hope helps.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -