Amphora-agent should log to a distinct location

This patch sets up a seperate log file for the amphora-agent
and logrotate to manage this new log.

Co-Authored-By: Adam Harwell <flux.adam@gmail.com>
Co-Authored-By: Michael Johnson <johnsomor@gmail.com>
Change-Id: Ia7b057642d7a567d685d989d1c689d5f3481e73e
This commit is contained in:
Adam Harwell 2016-12-13 17:22:23 -08:00
parent 264f3b58d1
commit bf8aac5561
5 changed files with 26 additions and 2 deletions

View File

@ -1,4 +1,5 @@
dib-init-system dib-init-system
install-static
package-installs package-installs
pip-and-virtualenv pip-and-virtualenv
source-repositories source-repositories

View File

@ -7,6 +7,8 @@ Wants=syslog.service
ExecStart=/usr/local/bin/amphora-agent --config-file /etc/octavia/amphora-agent.conf ExecStart=/usr/local/bin/amphora-agent --config-file /etc/octavia/amphora-agent.conf
KillMode=mixed KillMode=mixed
Restart=always Restart=always
ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/amphora-agent.pid"
PIDFile=/var/run/amphora-agent.pid
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -7,3 +7,12 @@ respawn
respawn limit 2 2 respawn limit 2 2
exec amphora-agent --config-file /etc/octavia/amphora-agent.conf exec amphora-agent --config-file /etc/octavia/amphora-agent.conf
post-start script
PID=`status amphora-agent | egrep -oi '([0-9]+)$' | head -n1`
echo $PID > /var/run/amphora-agent.pid
end script
post-stop script
rm -f /var/run/amphora-agent.pid
end script

View File

@ -0,0 +1,12 @@
/var/log/amphora-agent.log {
daily
rotate 10
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
kill -s SIGUSR1 $(cat /var/run/amphora-agent.pid)
endscript
}

View File

@ -77,8 +77,8 @@ def main():
'ca_certs': CONF.amphora_agent.agent_server_ca, 'ca_certs': CONF.amphora_agent.agent_server_ca,
'cert_reqs': True, 'cert_reqs': True,
'preload_app': True, 'preload_app': True,
'accesslog': '-', 'accesslog': '/var/log/amphora-agent.log',
'errorlog': '-', 'errorlog': '/var/log/amphora-agent.log',
'loglevel': 'debug', 'loglevel': 'debug',
} }
AmphoraAgent(server_instance.app, options).run() AmphoraAgent(server_instance.app, options).run()