fix error

This commit is contained in:
邱博亞 2021-03-06 18:48:14 +08:00
parent f95e94fdfb
commit c4dcacb3ee
2 changed files with 3 additions and 3 deletions

View File

@ -14,13 +14,13 @@ namespace :create_site do
location_path = site_construct.cert_ver_location_path
nginx_config = exec_command_by_user(ssh,"cat #{site_construct.nginx_file}")
if !site_construct.cert_ver_added_text.nil?
nginx_config = nginx_config.gsub(site_construct.cert_ver_added_text,'')
nginx_config = nginx_config.sub(site_construct.cert_ver_added_text,'')
end
file_name = location_path.split('/')[-1]
file_path = "#{site_construct.path}/#{site_construct.site_name}/tmp/#{file_name}"
site_construct.cert_ver_added_text = " location #{location_path}{#add_by_site_module\n alias #{file_path};\n }"
site_construct.save
server_array = nginx_config.scan(/^[ \t]*server[ \t]{(?:(?!server[ \t]*{).)+}/m)
server_array = nginx_config.scan(/^[ \t]*server[ \t]*{(?:(?!server[ \t]*{).)+}/m)
server_array.each do |server|
tmp = server[0...-1] + site_construct.cert_ver_added_text + "\n}"
nginx_config = nginx_config.sub(server,tmp)

View File

@ -24,7 +24,7 @@ namespace :create_site do
end
def exec_command_by_user(session,command)
output = session.exec!(command)
return output[0..-1]
return output[0...-1].gsub(/^\n[\n]+/,'')
end
def exec_ssh_command_by_sudo(session,command)
output = session.exec!("echo '#{@password}' | sudo -S #{command}")