Commit 1378bc9e authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Start using caddy

parent 6a80e015
...@@ -19,7 +19,7 @@ md5sum = f686f765e55d1dce2e55a400f0714b3e ...@@ -19,7 +19,7 @@ md5sum = f686f765e55d1dce2e55a400f0714b3e
[template-apache-frontend] [template-apache-frontend]
filename = instance-apache-frontend.cfg filename = instance-apache-frontend.cfg
md5sum = b47fa8613de158afd82036de4327c2bd md5sum = 599a3573badda54f42c8d7a004295adc
[template-apache-replicate] [template-apache-replicate]
filename = instance-apache-replicate.cfg.in filename = instance-apache-replicate.cfg.in
...@@ -37,8 +37,8 @@ md5sum = d103143e5d50682bd5ad43117d82e2fa ...@@ -37,8 +37,8 @@ md5sum = d103143e5d50682bd5ad43117d82e2fa
filename = templates/replicate-publish-slave-information.cfg.in filename = templates/replicate-publish-slave-information.cfg.in
md5sum = 665e83d660c9b779249b2179d7ce4b4e md5sum = 665e83d660c9b779249b2179d7ce4b4e
[template-apache-frontend-configuration] [template-caddy-frontend-configuration]
filename = templates/apache.conf.in filename = templates/Caddyfile.in
md5sum = 75ba24f0447240db20250a88a1ebc524 md5sum = 75ba24f0447240db20250a88a1ebc524
[template-custom-slave-list] [template-custom-slave-list]
...@@ -85,6 +85,6 @@ md5sum = 117238225b3fc3c5b5be381815f44c67 ...@@ -85,6 +85,6 @@ md5sum = 117238225b3fc3c5b5be381815f44c67
filename = templates/apache-lazy-script-call.sh.in filename = templates/apache-lazy-script-call.sh.in
md5sum = ebe5d3d19923eb812a40019cb11276d8 md5sum = ebe5d3d19923eb812a40019cb11276d8
[template-apache-graceful-script] [template-caddy-graceful-script]
filename = templates/apache-graceful-script.sh.in filename = templates/caddy-graceful-script.sh.in
md5sum = 41299cc64200e7b8217fb9dec20bb8b9 md5sum = d5a00bde52b0720e210fcd8ef352a583
...@@ -67,9 +67,9 @@ filename = custom-virtualhost.conf.in ...@@ -67,9 +67,9 @@ filename = custom-virtualhost.conf.in
<=download-template <=download-template
filename = replicate-publish-slave-information.cfg.in filename = replicate-publish-slave-information.cfg.in
[template-apache-frontend-configuration] [template-caddy-frontend-configuration]
<=download-template <=download-template
filename = apache.conf.in filename = Caddyfile.in
[template-custom-slave-list] [template-custom-slave-list]
<=download-template <=download-template
...@@ -127,9 +127,9 @@ mode = 0644 ...@@ -127,9 +127,9 @@ mode = 0644
<=download-template <=download-template
filename = apache-lazy-script-call.sh.in filename = apache-lazy-script-call.sh.in
[template-apache-graceful-script] [template-caddy-graceful-script]
<=download-template <=download-template
filename = apache-graceful-script.sh.in filename = caddy-graceful-script.sh.in
# Migrated from KVM recipe # Migrated from KVM recipe
[http-proxy] [http-proxy]
......
...@@ -10,7 +10,7 @@ parts = ...@@ -10,7 +10,7 @@ parts =
logrotate-entry-apache logrotate-entry-apache
apache-frontend apache-frontend
switch-apache-softwaretype switch-apache-softwaretype
frontend-apache-graceful frontend-caddy-graceful
dynamic-template-default-vh dynamic-template-default-vh
not-found-html not-found-html
promise-frontend-apache-configuration promise-frontend-apache-configuration
...@@ -170,7 +170,7 @@ extra-context = ...@@ -170,7 +170,7 @@ extra-context =
key template_default_slave_configuration software-release-path:template-default-slave-virtualhost key template_default_slave_configuration software-release-path:template-default-slave-virtualhost
key template_cached_slave_configuration software-release-path:template-cached-slave-virtualhost key template_cached_slave_configuration software-release-path:template-cached-slave-virtualhost
raw software_type single-custom-personal raw software_type single-custom-personal
key frontend_lazy_graceful_reload frontend-apache-lazy-graceful:rendered key frontend_lazy_graceful_reload frontend-caddy-lazy-graceful:rendered
section logrotate_dict logrotate section logrotate_dict logrotate
section frontend_configuration frontend-configuration section frontend_configuration frontend-configuration
section apache_configuration apache-configuration section apache_configuration apache-configuration
...@@ -193,7 +193,7 @@ extra-context = ...@@ -193,7 +193,7 @@ extra-context =
# Deploy Apache Frontend (new way, no recipe, jinja power) # Deploy Apache Frontend (new way, no recipe, jinja power)
[dynamic-apache-frontend-template] [dynamic-apache-frontend-template]
< = jinja2-template-base < = jinja2-template-base
template = ${template-apache-frontend-configuration:target} template = ${template-caddy-frontend-configuration:target}
rendered = $${apache-configuration:frontend-configuration} rendered = $${apache-configuration:frontend-configuration}
extra-context = extra-context =
key httpd_home software-release-path:caddy-location key httpd_home software-release-path:caddy-location
...@@ -224,8 +224,8 @@ extra-context = ...@@ -224,8 +224,8 @@ extra-context =
[apache-frontend] [apache-frontend]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = ${caddy:location}/bin/Caddy -f $${dynamic-apache-frontend-template:rendered} -DFOREGROUND command-line = ${caddy:output} -conf $${dynamic-apache-frontend-template:rendered}
wrapper-path = $${directory:service}/frontend_apache wrapper-path = $${directory:service}/frontend_caddy
wait-for-files = wait-for-files =
$${ca-frontend:cert-file} $${ca-frontend:cert-file}
$${ca-frontend:key-file} $${ca-frontend:key-file}
...@@ -247,13 +247,13 @@ vh-ssl = $${:slave-configuration}/ssl ...@@ -247,13 +247,13 @@ vh-ssl = $${:slave-configuration}/ssl
slave-log = $${directory:log}/httpd slave-log = $${directory:log}/httpd
[apache-configuration] [apache-configuration]
frontend-configuration = $${directory:etc}/apache_frontend.conf frontend-configuration = $${directory:etc}/Caddyfile
access-log = $${directory:log}/frontend-apache-access.log access-log = $${directory:log}/frontend-apache-access.log
error-log = $${directory:log}/frontend-apache-error.log error-log = $${directory:log}/frontend-apache-error.log
pid-file = $${directory:run}/httpd.pid pid-file = $${directory:run}/httpd.pid
protected-path = / protected-path = /
access-control-string = none access-control-string = none
frontend-configuration-verification = ${caddy:location}/bin/Caddy -Sf $${:frontend-configuration} > /dev/null frontend-configuration-verification = ${caddy:output} -validate -conf $${:frontend-configuration} > /dev/null
frontend-graceful-command = $${:frontend-configuration-verification}; if [ $? -eq 0 ]; then kill -USR1 $(cat $${:pid-file}); fi frontend-graceful-command = $${:frontend-configuration-verification}; if [ $? -eq 0 ]; then kill -USR1 $(cat $${:pid-file}); fi
# Comunication with ats # Comunication with ats
...@@ -264,8 +264,8 @@ ssl-cache-through-port = 26012 ...@@ -264,8 +264,8 @@ ssl-cache-through-port = 26012
# Create wrapper for "apachectl conftest" in bin # Create wrapper for "apachectl conftest" in bin
[configtest] [configtest]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = ${caddy:location}/bin/Caddy -f $${directory:etc}/apache_frontend.conf -t command-line = ${caddy:output} -conf $${apache-configuration:frontend-configuration} -validate
wrapper-path = $${directory:bin}/apache-configtest wrapper-path = $${directory:bin}/caddy-configtest
[certificate-authority] [certificate-authority]
recipe = slapos.cookbook:certificate_authority recipe = slapos.cookbook:certificate_authority
...@@ -291,8 +291,8 @@ crl = $${directory:ca-dir}/crl/ ...@@ -291,8 +291,8 @@ crl = $${directory:ca-dir}/crl/
recipe = slapos.cookbook:certificate_authority.request recipe = slapos.cookbook:certificate_authority.request
key-file = $${cadirectory:certs}/apache_frontend.key key-file = $${cadirectory:certs}/apache_frontend.key
cert-file = $${cadirectory:certs}/apache_frontend.crt cert-file = $${cadirectory:certs}/apache_frontend.crt
executable = $${directory:service}/frontend_apache executable = $${directory:service}/frontend_caddy
wrapper = $${directory:service}/frontend_apache wrapper = $${directory:service}/frontend_caddy
key-content = $${instance-parameter:configuration.apache-key} key-content = $${instance-parameter:configuration.apache-key}
cert-content = $${instance-parameter:configuration.apache-certificate} cert-content = $${instance-parameter:configuration.apache-certificate}
# Put domain name # Put domain name
...@@ -347,7 +347,7 @@ name = apache ...@@ -347,7 +347,7 @@ name = apache
log = $${apache-configuration:error-log} $${apache-configuration:access-log} log = $${apache-configuration:error-log} $${apache-configuration:access-log}
frequency = daily frequency = daily
rotatep-num = 30 rotatep-num = 30
post = $${frontend-apache-lazy-graceful:rendered} & post = $${frontend-caddy-lazy-graceful:rendered} &
sharedscripts = true sharedscripts = true
notifempty = true notifempty = true
create = true create = true
...@@ -462,28 +462,28 @@ mode = 700 ...@@ -462,28 +462,28 @@ mode = 700
### End of ATS sections ### End of ATS sections
### Apaches Graceful and promises ### Apaches Graceful and promises
[frontend-apache-graceful-bin] [frontend-caddy-graceful-bin]
< = jinja2-template-base < = jinja2-template-base
template = ${template-wrapper:output} template = ${template-wrapper:output}
rendered = $${directory:bin}/frontend-apache-safe-graceful rendered = $${directory:bin}/frontend-caddy-safe-graceful
mode = 0700 mode = 0700
extra-context = extra-context =
key content apache-configuration:frontend-graceful-command key content apache-configuration:frontend-graceful-command
[frontend-apache-graceful] [frontend-caddy-graceful]
< = jinja2-template-base < = jinja2-template-base
template = ${template-apache-graceful-script:target} template = ${template-caddy-graceful-script:target}
rendered = $${directory:etc-run}/frontend-apache-safe-graceful rendered = $${directory:etc-run}/frontend-caddy-safe-graceful
mode = 0700 mode = 0700
extra-context = extra-context =
key directory_run directory:run key directory_run directory:run
key directory_etc directory:etc key directory_etc directory:etc
key apache_graceful_reload_command apache-configuration:frontend-graceful-command key caddy_graceful_reload_command apache-configuration:frontend-graceful-command
[frontend-apache-lazy-graceful] [frontend-caddy-lazy-graceful]
< = jinja2-template-base < = jinja2-template-base
template = ${template-apache-lazy-script-call:target} template = ${template-apache-lazy-script-call:target}
rendered = $${directory:bin}/frontend-apache-lazy-graceful rendered = $${directory:bin}/frontend-caddy-lazy-graceful
mode = 0700 mode = 0700
pid-file = $${directory:run}/lazy-graceful.pid pid-file = $${directory:run}/lazy-graceful.pid
extra-context = extra-context =
......
#!/bin/sh
RUN_DIR={{ directory_run }}
ETC_DIR={{ directory_etc }}
APACHE_SIGNATURE_FILE=$RUN_DIR/apache_configuration.signature
NAPACHE_SIGNATURE_FILE=$RUN_DIR/napache_configuration.signature
touch $APACHE_SIGNATURE_FILE
sha256sum $ETC_DIR/apache*.conf $ETC_DIR/apache-*.d/*.conf $ETC_DIR/apache-*.d/ssl/*.*key $ETC_DIR/apache-*.d/ssl/*.*crt* | sort -k 66 > $NAPACHE_SIGNATURE_FILE
# If no diff, no restart for now
if diff "$APACHE_SIGNATURE_FILE" "$NAPACHE_SIGNATURE_FILE"; then
echo "Nothing Changed, so nothing to reload"
exit 0
fi
echo "Reloading apache.."
{{ apache_graceful_reload_command }}
mv "$NAPACHE_SIGNATURE_FILE" "$APACHE_SIGNATURE_FILE"
#!/bin/sh
RUN_DIR={{ directory_run }}
ETC_DIR={{ directory_etc }}
CADDY_SIGNATURE_FILE=$RUN_DIR/caddy_configuration.signature
NCADDY_SIGNATURE_FILE=$RUN_DIR/ncaddy_configuration.signature
touch $CADDY_SIGNATURE_FILE
sha256sum $ETC_DIR/Caddyfile $ETC_DIR/caddy-*.d/*.conf $ETC_DIR/caddy-*.d/ssl/*.*key $ETC_DIR/caddy-*.d/ssl/*.*crt* | sort -k 66 > $NCADDY_SIGNATURE_FILE
# If no diff, no restart for now
if diff "$CADDY_SIGNATURE_FILE" "$NCADDY_SIGNATURE_FILE"; then
echo "Nothing Changed, so nothing to reload"
exit 0
fi
echo "Reloading caddy.."
{{ caddy_graceful_reload_command }}
mv "$NCADDY_SIGNATURE_FILE" "$CADDY_SIGNATURE_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