Commit d2bc05c6 authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Implement log file for backend-haproxy

rsyslogd is used, as haproxy does not support writing log files by its own.
parent 6cc11cdf
......@@ -22,7 +22,7 @@ md5sum = c801b7f9f11f0965677c22e6bbe9281b
[template-apache-frontend]
filename = instance-apache-frontend.cfg.in
md5sum = c0325f8cabba57b399c3f5ed2c6a01c4
md5sum = 3ca820aa3ae75dbdaf09f653868d597e
[template-caddy-replicate]
filename = instance-apache-replicate.cfg.in
......@@ -30,7 +30,7 @@ md5sum = 6d7113ebf0c46b0e4c72c128ebb647db
[template-slave-list]
_update_hash_filename_ = templates/apache-custom-slave-list.cfg.in
md5sum = c72c8d6d0189aa19a743c96e8d7215cf
md5sum = 593aaf3883ebca93fb85b2387988b4a8
[template-replicate-publish-slave-information]
_update_hash_filename_ = templates/replicate-publish-slave-information.cfg.in
......@@ -54,7 +54,7 @@ md5sum = 82c3908c9f6346356179646211058bf5
[template-backend-haproxy-configuration]
_update_hash_filename_ = templates/backend-haproxy.cfg.in
md5sum = eb517d1f051f0631744a512af84b9a3b
md5sum = 1d0922a1bd4210e61a6062ac450990aa
[template-log-access]
_update_hash_filename_ = templates/template-log-access.conf.in
......@@ -115,3 +115,7 @@ md5sum = 38792c2dceae38ab411592ec36fff6a8
[template-kedifa]
filename = instance-kedifa.cfg.in
md5sum = 9d6111a5d6bc07e708116ca331925241
[template-rsyslogd-conf]
_update_hash_filename_ = templates/rsyslogd.conf.in
md5sum = 6f0fd930ffb3230b7e8c781f88693d69
......@@ -10,6 +10,7 @@ extends =
../../component/trafficserver/buildout.cfg
../../component/6tunnel/buildout.cfg
../../component/xz-utils/buildout.cfg
../../component/rsyslogd/buildout.cfg
../../component/haproxy/buildout.cfg
../../stack/caucase/buildout.cfg
......@@ -96,6 +97,7 @@ sixtunnel = ${6tunnel:location}
caddy = ${caddy:output}
caddy_location = ${caddy:location}
haproxy_executable = ${haproxy:location}/sbin/haproxy
rsyslogd_executable = ${rsyslogd:location}/sbin/rsyslogd
curl = ${curl:location}
dash = ${dash:location}
gzip = ${gzip:location}
......@@ -111,6 +113,7 @@ xz_location = ${xz-utils:location}
monitor_template = ${monitor-template:output}
template_backend_haproxy_configuration = ${template-backend-haproxy-configuration:target}
template_rsyslogd_conf = ${template-rsyslogd-conf:target}
template_caddy_frontend_configuration = ${template-caddy-frontend-configuration:target}
template_graceful_script = ${template-graceful-script:target}
template_validate_script = ${template-validate-script:target}
......@@ -224,3 +227,6 @@ mode = 0644
[template-configuration-state-script]
<=download-template
[template-rsyslogd-conf]
<=download-template
......@@ -46,6 +46,7 @@ parts =
promise-backend-haproxy-http
promise-backend-haproxy-https
promise-backend-haproxy-configuration
logrotate-entry-backend-haproxy
# Create all needed directories
[directory]
......@@ -61,6 +62,7 @@ template = ${buildout:directory}/template/
backup = ${:srv}/backup
log = ${:var}/log
run = ${:var}/run
backend-haproxy-rsyslogd-spool = ${:run}/backend-haproxy-rsyslogd-spool
service = ${:etc}/service
etc-run = ${:etc}/run
......@@ -152,6 +154,7 @@ context =
template-empty = {{ parameter_dict['template_empty'] }}
template-default-slave-virtualhost = {{ parameter_dict['template_default_slave_virtualhost'] }}
template-backend-haproxy-configuration = {{ parameter_dict['template_backend_haproxy_configuration'] }}
template-rsyslogd-conf = {{ parameter_dict['template_rsyslogd_conf'] }}
caddy-location = {{ parameter_dict['caddy_location'] }}
[kedifa-login-config]
......@@ -660,6 +663,7 @@ config-port = ${backend-haproxy-configuration:https-port}
[backend-haproxy-configuration]
file = ${directory:etc}/backend-haproxy.cfg
pid-file = ${directory:run}/backend-haproxy.pid
log-socket = ${backend-haproxy-rsyslogd:log-socket}
graceful-command = ${backend-haproxy-validate:rendered} && kill -USR2 $(cat ${:pid-file})
http-port = ${configuration:backend-haproxy-http-port}
https-port = ${configuration:backend-haproxy-https-port}
......@@ -682,6 +686,13 @@ wrapper-path = ${directory:service}/backend-haproxy
hash-existing-files = ${buildout:directory}/software_release/buildout.cfg
hash-files = ${backend-haproxy-wrapper:rendered}
[logrotate-entry-backend-haproxy]
<= logrotate-entry-base
name = backend-haproxy
log = ${backend-haproxy-rsyslogd-configuration:log-file}
rotate-num = 30
post = kill -HUP $(cat ${backend-haproxy-rsyslogd-configuration:pid-file})
[backend-haproxy-configuration-state]
<= jinja2-template-base
template = {{ parameter_dict['template_configuration_state_script'] }}
......@@ -755,6 +766,28 @@ content =
context =
key content :content
[backend-haproxy-rsyslogd-configuration]
<= jinja2-template-base
template = {{ parameter_dict['template_rsyslogd_conf'] }}
rendered = ${directory:etc}/backend-haproxy-rsyslogd.conf
# Note: log-socket shall be backend-haproxy-rsyslogd.sock to refer the part name,
# but it results with socket path limit
log-socket = ${directory:run}/bhlog.sck
log-file = ${directory:log}/backend-haproxy.log
pid-file = ${directory:run}/backend-haproxy-rsyslogd.pid
extra-context =
key socket :log-socket
key log_file :log-file
key spool_directory directory:backend-haproxy-rsyslogd-spool
[backend-haproxy-rsyslogd]
recipe = slapos.cookbook:wrapper
command-line = {{ parameter_dict['rsyslogd_executable'] }} -i ${backend-haproxy-rsyslogd-configuration:pid-file} -n -f ${backend-haproxy-rsyslogd-configuration:rendered}
wrapper-path = ${directory:service}/backend-haproxy-rsyslogd
hash-existing-files = ${buildout:directory}/software_release/buildout.cfg
log-socket = ${backend-haproxy-rsyslogd-configuration:log-socket}
log-file = ${backend-haproxy-rsyslogd-configuration:log-file}
#######
# Monitoring sections
#
......
......@@ -422,6 +422,7 @@ extra-context =
[backend-haproxy-config]
file = {{ backend_haproxy_configuration['file'] }}
pid-file = {{ backend_haproxy_configuration['pid-file'] }}
log-socket = {{ backend_haproxy_configuration['log-socket'] }}
local-ipv4 = {{ dumps('' ~ local_ipv4) }}
http-port = {{ ('' ~ backend_haproxy_configuration['http-port']) }}
https-port = {{ ('' ~ backend_haproxy_configuration['https-port']) }}
......
......@@ -5,7 +5,7 @@ global
# master-worker is compatible with foreground with process management
master-worker
log stderr local0
log {{ configuration['log-socket'] }} local0
defaults
log global
mode http
......
module(
load="imuxsock"
SysSock.Name="{{ socket }}")
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$FileCreateMode 0600
$DirCreateMode 0700
$Umask 0022
$WorkDirectory {{ spool_directory }}
*.* {{ log_file }}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment