意外令牌附近的Capistrano语法错误`('

时间:2015-11-11 00:23:48

标签: ruby-on-rails amazon-web-services capistrano

我正在尝试在aws服务器上部署rails应用程序。我收到以下错误消息。我试图运行“brew install bash'根据网站上的建议,但不起作用。

DEBUG [125bed1f] bash:-c:第0行:意外令牌附近的语法错误(' DEBUG [125bed1f] bash: -c: line 0: cd / var / www / myapp / repo&& (GIT_ASKPASS = / bin / echo GIT_SSH = / tmp / myapp / git-ssh.sh / usr / bin / env git archive(detached | tar -x -f - -C / var / www / myapp / releases / 20151111001549)& #39; 帽子流产! SSHKit :: Runner :: ExecuteError:作为ec2-user@52.1.1.1执行时出现异常:git exit status:1 git stdout:bash:-c:第0行:意外令牌附近的语法错误(' bash: -c: line 0: cd / var / www / myapp / repo&& (GIT_ASKPASS = / bin / echo GIT_SSH = / tmp / myapp / git-ssh.sh / usr / bin / env git archive(detached | tar -x -f - -C / var / www / myapp / releases / 20151111001549)& #39; git stderr:没有写的

这是deploy.rb文件

# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'myapp'
set :repo_url, 'git@github.com:myaccount/myapp'

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
# parses out the current branch you're on. See: http://www.harukizaemon.com/2008/05/deploying-branches-with-capistrano.html
current_branch = `git branch`.match(/\* (\S+)\s/m)[1]

# use the branch specified as a param, then use the current branch. If all fails use master branch
set :branch, ENV['BRANCH'] || current_branch || 'develop' # you can use the 'branch' parameter on deployment to specify the branch you wish to deploy

# issue of capistrano https://github.com/capistrano/bundler/issues/45#issuecomment-47428203
set :bundle_binstubs, nil

# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
set :pty, true

# Default value for :linked_files is []
set :linked_files, fetch(:linked_files, []).push('config/database.yml', '.env')

# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
# set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_access.log"
set :puma_error_log, "#{shared_path}/log/puma_error.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 16]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, false
set :puma_preload_app, true
set :puma_prune_bundler, false
set :puma_bind, 'tcp://0.0.0.0:9292'

# whenever command
set :whenever_command, -> { [:bundle, :exec, :whenever] }

# update the Gemfile path
# set :bundle_gemfile, -> { current_path.join('Gemfile') }

namespace :puma do
  desc 'Create Directories for Puma Pids and Socket'
  task :make_dirs do
    on roles(:app) do
      execute "mkdir #{shared_path}/tmp/sockets -p"
      execute "mkdir #{shared_path}/tmp/pids -p"
    end
  end

  before :start, :make_dirs
end


namespace :deploy do
  # https://coderwall.com/p/ttrhow/deploying-rails-app-using-nginx-puma-and-capistrano-3
  desc 'Make sure local git is in sync with remote.'
  task :check_revision do
    on roles(:app) do
      unless `git rev-parse #{current_branch}` == `git rev-parse origin/#{current_branch}`
        puts 'WARNING: HEAD is not the same as origin/master'
        puts 'Run `git push` to sync changes.'
        exit
      end
    end
  end

  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'
    end
  end

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      invoke 'puma:restart'
    end
  end

  # ps aux | grep puma    # Get puma pid
  # kill -s SIGUSR2 pid   # Restart puma
  # kill -s SIGTERM pid   # Stop puma
  before :starting, :check_revision
  after :finishing, :compile_assets
  after :finishing, :cleanup
  after :finishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

1 个答案:

答案 0 :(得分:0)

看起来我所在的分支是起源/测试 - 一个独立的头。我按照此堆栈溢出页面上的说明进行了解答。

git: switch branch without detaching head