Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions deploy_gcp/seismic_deploy/ssh/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from deploy_gcp.seismic_deploy.ssh.connection import SSHConnection
from deploy_gcp.seismic_deploy.templates import (
read_bash_aliases,
read_logrotate_conf,
render_lua_scripts,
render_nginx,
render_supervisor,
Expand Down Expand Up @@ -44,6 +45,12 @@ def deploy_nginx(conn: SSHConnection, config: DeploymentConfig) -> None:
click.echo(" Uploading nginx config...")
conn.upload_content(content, "/tmp/nginx.conf")
conn.exec("sudo mv /tmp/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf")
click.echo(" Installing logrotate config...")
conn.upload_content(read_logrotate_conf(), "/tmp/logrotate-openresty")
conn.exec("sudo mv /tmp/logrotate-openresty /etc/logrotate.d/openresty")
conn.exec("sudo chown root:root /etc/logrotate.d/openresty")
conn.exec("sudo chmod 644 /etc/logrotate.d/openresty")

click.echo(" Testing nginx config...")
conn.exec("sudo openresty -t")
click.echo(" Reloading OpenResty...")
Expand Down
5 changes: 5 additions & 0 deletions deploy_gcp/seismic_deploy/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def render_lua_scripts(
return scripts


def read_logrotate_conf() -> str:
"""Read the OpenResty logrotate config as-is (no substitution needed)."""
return (TEMPLATES_DIR / "logrotate-openresty").read_text()


def read_bash_aliases() -> str:
"""Read the bash_aliases template as-is (no substitution needed)."""
return (TEMPLATES_DIR / "bash_aliases").read_text()
Expand Down
15 changes: 15 additions & 0 deletions deploy_gcp/templates/logrotate-openresty
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/usr/local/openresty/nginx/logs/*.log {
daily
maxsize 100M
rotate 14
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
if [ -f /usr/local/openresty/nginx/logs/nginx.pid ]; then
kill -USR1 "$(cat /usr/local/openresty/nginx/logs/nginx.pid)"
fi
endscript
}
Loading