This commit is contained in:
BoHung Chiu 2021-06-05 18:53:17 +08:00
parent a82e6bca92
commit 05a359e0fa
2 changed files with 6 additions and 0 deletions

View File

@ -35,6 +35,7 @@
<a href="#" title="<%=t("client_management.close_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary close_site" data-id="<%=site.id.to_s%>"><%=t('client_management.close_site')%></a>
<a href="#" title="Restart <%=site.domain_name%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>"><%=t('client_management.restart_site')%></a>
<% elsif site.status == "closed" %>
<a href="#" title="<%=t("client_management.delete_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary delete_site" data-id="<%=site.id.to_s%>"><%=t('client_management.delete_site')%></a>
<a href="#" title="<%=t("client_management.start_site_for_site",{:site=>site.domain_name})%>" class="btn btn-primary open_site" data-id="<%=site.id.to_s%>"><%=t('client_management.start_site')%></a>
<% end%>
<% if site.status.present? %>

View File

@ -20,6 +20,11 @@ namespace :create_site do
end
Net::SSH.start(ip , user , password: password) do |ssh|
@site_construct.update!(:infos=>[])
if @site_construct.status != "closed"
update_infos("Closing site #{@site_construct.site_name}...")
end
exec_ssh_command_by_sudo(ssh,"kill -s TERM `cat tmp/pids/unicorn.pid`")
exec_ssh_command_by_sudo(ssh,"kill -s TERM `fuser tmp/unicorn.sock`")
update_infos("deleting database for #{@site_construct.site_name}")
db_name = exec_ssh_command_by_sudo(ssh,"echo `cat #{@site_construct.path}/#{@site_construct.get_site_name}/config/mongoid.yml | grep 'database'`").split("database:").last.strip
exec_ssh_command_by_sudo(ssh,"bash -l -c 'echo \"db.dropDatabase()\" | mongo --shell \'#{db_name}\''")