Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Capistrano 2任务文件,语法需要修复_Ruby On Rails_Ruby_Wordpress_Capistrano - Fatal编程技术网

Ruby on rails Capistrano 2任务文件,语法需要修复

Ruby on rails Capistrano 2任务文件,语法需要修复,ruby-on-rails,ruby,wordpress,capistrano,Ruby On Rails,Ruby,Wordpress,Capistrano,在下面找到capistrano 2部署中的my tasks.rb文件。它最初来自WP Stack,我已经对它进行了黑客攻击,因此允许我执行“cap dev db:sync”以及“cap staging db:sync”现在工作正常,但我将“end”语法放在了不正确的地方,并破坏了末尾的“db”部分,因为我的部署现在报告“db:make_config”不存在。我不知道我在做什么,我盲目地尝试移动“end”语法,但没有任何效果。有想法的人可以帮我看一下,并指出可能需要移动的内容 namespace

在下面找到capistrano 2部署中的my tasks.rb文件。它最初来自WP Stack,我已经对它进行了黑客攻击,因此允许我执行“cap dev db:sync”以及“cap staging db:sync”现在工作正常,但我将“end”语法放在了不正确的地方,并破坏了末尾的“db”部分,因为我的部署现在报告“db:make_config”不存在。我不知道我在做什么,我盲目地尝试移动“end”语法,但没有任何效果。有想法的人可以帮我看一下,并指出可能需要移动的内容

namespace :shared do
task :make_shared_dir do
    run "if [ ! -d #{shared_path}/files ]; then mkdir #{shared_path}/files; fi"
end
task :make_symlinks do
    run "if [ ! -h #{release_path}/shared ]; then ln -s #{shared_path}/files/ #{release_path}/shared; fi"
end
end

namespace :nginx do
desc "Restarts nginx"
task :restart do
    run "sudo /etc/init.d/nginx reload"
end
end

namespace :phpfpm do
desc" Restarts PHP-FPM"
task :restart do
    run "sudo /etc/init.d/php-fpm restart"
end
end

 namespace :git do
desc "Updates git submodule tags"
task :submodule_tags do
    run "if [ -d #{shared_path}/cached-copy/ ]; then cd #{shared_path}/cached-copy/ && git submodule foreach --recursive git fetch origin --tags; fi"
end
end

namespace :memcached do
desc "Restarts Memcached"
task :restart do
    run "echo 'flush_all' | nc localhost 11211", :roles => [:memcached]
end
desc "Updates the pool of memcached servers"
task :update do
    unless find_servers( :roles => :memcached ).empty? then
        mc_servers = '<?php return array( "' + find_servers( :roles => :memcached ).join( ':11211", "' ) + ':11211" ); ?>'
        run "echo '#{mc_servers}' > #{current_path}/memcached.php", :roles => :memcached
    end
end
end

namespace :db do
desc "Syncs the staging database from production"
task :sync, :roles => :web  do
if stage == :production then
    puts "[Error] You must run db:sync from staging with cap staging db:sync or from local with cap local db:sync"
        else
        if stage == :staging then
        puts "Hang on... this might take a while."
        random = rand( 10 ** 5 ).to_s.rjust( 5, '0' )
        p = wpdb[ :production ]
        s = wpdb[ :staging ]
        puts "db:sync"
        puts stage
        system "mysqldump -u #{p[:user]} --result-file=/tmp/wpstack-#{random}.sql -h #{p[:host]} -p#{p[:password]} #{p[:name]}"
        system "mysql -u #{s[:user]} -h #{s[:host]} -p#{s[:password]} #{s[:name]} < /tmp/wpstack-#{random}.sql && rm /tmp/wpstack-#{random}.sql"
        puts "Database synced to staging"
        # memcached.restart
        puts "Memcached flushed"
end
if stage == :dev then
puts "Hang on... this might take a while."
random = rand( 10 ** 5 ).to_s.rjust( 5, '0' )
p = wpdb[ :production ]
d = wpdb[ :dev ]
puts "db:sync"
puts dev
system "mysqldump -u #{p[:user]} --result-file=/tmp/wpstack-#{random}.sql -h #{p[:host]} -p#{p[:password]} #{p[:name]}"
system "mysql -u #{d[:user]} -h #{d[:host]} -p#{d[:password]} #{d[:name]} < /tmp/wpstack-#{random}.sql && rm /tmp/wpstack-#{random}.sql"
puts "Database synced to development repo"
# memcached.restart
puts "Memcached flushed"
end
desc "Sets the database credentials (and other settings) in wp-config.php"
task :make_config do
    set :staging_domain, '077397919.45' unless defined? staging_domain
    {:'%%WP_STAGING_DOMAIN%%' => staging_domain, :'%%WP_STAGE%%' => stage, :'%%DB_NAME%%' => wpdb[stage][:name], :'%%DB_USER%%' => wpdb[stage][:user], :'%%DB_PASSWORD%%' => wpdb[stage][:password], :'%%DB_HOST%%' => wpdb[stage][:host]}.each do |k,v|
        run "sed -i 's/#{k}/#{v}/' #{release_path}/wp-config.php", :roles => :web
    end
end
end
名称空间:共享do
任务:使_共享_dir do
运行“如果[!-d{shared\u path}/files];然后运行mkdir{shared\u path}/files;fi”
终止
任务:使_符号链接
运行“如果[!-h{release}/shared];那么ln-s{shared}/files/{release}/shared;fi”
终止
终止
名称空间:nginx do
描述“重新启动nginx”
任务:重新启动do
运行“sudo/etc/init.d/nginx reload”
终止
终止
名称空间:phpfpmdo
描述“重新启动PHP-FPM”
任务:重新启动do
运行“sudo/etc/init.d/php-fpm restart”
终止
终止
名称空间:gitdo
desc“更新git子模块标记”
任务:子模块_标记do
运行“if[-d#{shared_path}/cached copy/];然后运行cd#{shared_path}/cached copy/&&git子模块foreach--recursive git fetch origin--tags;fi”
终止
终止
名称空间:memcached do
desc“重新启动Memcached”
任务:重新启动do
运行“echo'flush_all'| nc localhost 11211”,:roles=>[:memcached]
终止
desc“更新memcached服务器池”
任务:更新do
除非查找服务器(:roles=>:memcached)。是否为空?然后
mc_servers='试试这个:

namespace :shared do
  task :make_shared_dir do
    run "if [ ! -d #{shared_path}/files ]; then mkdir #{shared_path}/files; fi"
  end

  task :make_symlinks do
    run "if [ ! -h #{release_path}/shared ]; then ln -s #{shared_path}/files/ #{release_path}/shared; fi"
  end
end

namespace :nginx do
  desc "Restarts nginx"
  task :restart do
    run "sudo /etc/init.d/nginx reload"
  end
end

namespace :phpfpm do
  desc" Restarts PHP-FPM"
  task :restart do
    run "sudo /etc/init.d/php-fpm restart"
  end
end

namespace :git do
  desc "Updates git submodule tags"
  task :submodule_tags do
    run "if [ -d #{shared_path}/cached-copy/ ]; then cd #{shared_path}/cached-copy/ && git submodule foreach --recursive git fetch origin --tags; fi"
  end
end

namespace :memcached do
  desc "Restarts Memcached"
  task :restart do
    run "echo 'flush_all' | nc localhost 11211", :roles => [:memcached]
  end

  desc "Updates the pool of memcached servers"
  task :update do
    unless find_servers( :roles => :memcached ).empty?
      mc_servers = '<?php return array( "' + find_servers( :roles => :memcached ).join( ':11211", "' ) + ':11211" ); ?>'
      run "echo '#{mc_servers}' > #{current_path}/memcached.php", :roles => :memcached
    end
  end
end

namespace :db do
  desc "Syncs the staging database from production"
  task :sync, :roles => :web do
    case stage
    when :production
      puts "[Error] You must run db:sync from staging with cap staging db:sync or from local with cap local db:sync"
    when :staging
      puts "Hang on... this might take a while."
      random = rand( 10 ** 5 ).to_s.rjust( 5, '0' )
      p = wpdb[ :production ]
      s = wpdb[ :staging ]
      puts "db:sync"
      puts stage
      system "mysqldump -u #{p[:user]} --result-file=/tmp/wpstack-#{random}.sql -h #{p[:host]} -p#{p[:password]} #{p[:name]}"
      system "mysql -u #{s[:user]} -h #{s[:host]} -p#{s[:password]} #{s[:name]} < /tmp/wpstack-#{random}.sql && rm /tmp/wpstack-#{random}.sql"
      puts "Database synced to staging"
      # memcached.restart
      puts "Memcached flushed"
    when :dev
      puts "Hang on... this might take a while."
      random = rand( 10 ** 5 ).to_s.rjust( 5, '0' )
      p = wpdb[ :production ]
      d = wpdb[ :dev ]
      puts "db:sync"
      puts dev
      system "mysqldump -u #{p[:user]} --result-file=/tmp/wpstack-#{random}.sql -h #{p[:host]} -p#{p[:password]} #{p[:name]}"
      system "mysql -u #{d[:user]} -h #{d[:host]} -p#{d[:password]} #{d[:name]} < /tmp/wpstack-#{random}.sql && rm /tmp/wpstack-#{random}.sql"
      puts "Database synced to development repo"
      # memcached.restart
      puts "Memcached flushed"
    end
  end

  desc "Sets the database credentials (and other settings) in wp-config.php"
  task :make_config do
    set :staging_domain, '077397919.45' unless defined? staging_domain
    {:'%%WP_STAGING_DOMAIN%%' => staging_domain, :'%%WP_STAGE%%' => stage, :'%%DB_NAME%%' => wpdb[stage][:name], :'%%DB_USER%%' => wpdb[stage][:user], :'%%DB_PASSWORD%%' => wpdb[stage][:password], :'%%DB_HOST%%' => wpdb[stage][:host]}.each do |k,v|
      run "sed -i 's/#{k}/#{v}/' #{release_path}/wp-config.php", :roles => :web
    end
  end
end
名称空间:共享do
任务:使_共享_dir do
运行“如果[!-d{shared\u path}/files];然后运行mkdir{shared\u path}/files;fi”
终止
任务:使_符号链接
运行“如果[!-h{release}/shared];那么ln-s{shared}/files/{release}/shared;fi”
终止
终止
名称空间:nginx do
描述“重新启动nginx”
任务:重新启动do
运行“sudo/etc/init.d/nginx reload”
终止
终止
名称空间:phpfpmdo
描述“重新启动PHP-FPM”
任务:重新启动do
运行“sudo/etc/init.d/php-fpm restart”
终止
终止
名称空间:gitdo
desc“更新git子模块标记”
任务:子模块_标记do
运行“if[-d#{shared_path}/cached copy/];然后运行cd#{shared_path}/cached copy/&&git子模块foreach--recursive git fetch origin--tags;fi”
终止
终止
名称空间:memcached do
desc“重新启动Memcached”
任务:重新启动do
运行“echo'flush_all'| nc localhost 11211”,:roles=>[:memcached]
终止
desc“更新memcached服务器池”
任务:更新do
除非查找服务器(:roles=>:memcached)。是否为空?

mc_servers='使用一个编辑器来为您调整内容。在vim中选择所有内容(
ggVG
)并与
=
对齐。您应该看到底部缺少两个
end