add Known as an application
This commit is contained in:
parent
7b6cafe8ad
commit
90fd8ce651
5 changed files with 98 additions and 0 deletions
BIN
blueprints/known-0.6.4.tgz
Normal file
BIN
blueprints/known-0.6.4.tgz
Normal file
Binary file not shown.
|
@ -19,6 +19,7 @@ docker pull indiehosters/postfix-forwarder
|
|||
docker pull indiehosters/nginx
|
||||
docker pull indiehosters/mysql
|
||||
docker pull indiehosters/wordpress
|
||||
docker pull indiehosters/known
|
||||
|
||||
# Install unit-files
|
||||
sudo cp /data/indiehosters/unit-files/* /etc/systemd/system && systemctl daemon-reload
|
||||
|
|
34
unit-files/known-discovery@.service
Normal file
34
unit-files/known-discovery@.service
Normal file
|
@ -0,0 +1,34 @@
|
|||
[Unit]
|
||||
Description=%p for %i etcd registration
|
||||
|
||||
# Requirements
|
||||
Requires=etcd.service
|
||||
|
||||
# Dependency ordering
|
||||
After=etcd.service
|
||||
After=known@%i.service
|
||||
|
||||
# Dependency binding
|
||||
BindsTo=known@%i.service
|
||||
|
||||
[Service]
|
||||
# Start
|
||||
## Test whether service is accessible and then register useful information
|
||||
ExecStart=/bin/bash -c ' \
|
||||
sleep 30; \
|
||||
while true; do \
|
||||
app=`echo %p | cut -d"-" -f1`; \
|
||||
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $app-%i`; \
|
||||
curl -f $ip; \
|
||||
if [ $? -eq 0 ]; then \
|
||||
etcdctl set /services/$app/%i \'{"ip":"\'$ip\'", "port":"80"}\' --ttl 60; \
|
||||
else \
|
||||
etcdctl rm /services/$app/%i; \
|
||||
fi; \
|
||||
sleep 50; \
|
||||
done'
|
||||
|
||||
# Stop
|
||||
ExecStop=-/bin/bash -euxc ' \
|
||||
app=`echo %p | cut -d"-" -f1`; \
|
||||
/usr/bin/etcdctl rm /services/$app/%i
|
30
unit-files/known-importer@.service
Normal file
30
unit-files/known-importer@.service
Normal file
|
@ -0,0 +1,30 @@
|
|||
[Unit]
|
||||
Description=WordPress importer
|
||||
|
||||
# Dependency ordering
|
||||
After=mysql@%i.service
|
||||
Before=known@%i.service
|
||||
Before=backup@%i.timer
|
||||
|
||||
# Dependency binding
|
||||
BindsTo=known@%i.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
Environment=DOMAIN=%i
|
||||
ExecStartPre=/data/indiehosters/scripts/backup-init.sh
|
||||
ExecStartPre=/data/indiehosters/scripts/import.sh
|
||||
ExecStart=/bin/bash -euxc ' \
|
||||
cp /data/domains/%i/TLS/%i.pem /data/runtime/haproxy/approved-certs/%i.pem; \
|
||||
known_folder=/data/domains/%i/known; \
|
||||
if [ ! -d $known_folder/known-content ]; then \
|
||||
mkdir -p $known_folder; \
|
||||
cd $known_folder; \
|
||||
tar xvzf /data/indiehosters/blueprints/known-0.6.4.tgz; \
|
||||
touch .htaccess; \
|
||||
fi; \
|
||||
cat /data/domains/%i/mysql/.env | sed s/MYSQL_PASS/DB_PASS/ > $known_folder/.env'
|
||||
|
||||
[Install]
|
||||
WantedBy=known@%i.service
|
33
unit-files/known@.service
Normal file
33
unit-files/known@.service
Normal file
|
@ -0,0 +1,33 @@
|
|||
[Unit]
|
||||
Description=%p-%i
|
||||
|
||||
# Requirements
|
||||
Requires=docker.service
|
||||
Requires=etcd.service
|
||||
Requires=mysql@%i.service
|
||||
Requires=%p-importer@%i.service
|
||||
Requires=%p-discovery@%i.service
|
||||
Requires=backup@%i.timer
|
||||
|
||||
# Dependency ordering
|
||||
After=docker.service
|
||||
After=mysql@%i.service
|
||||
After=%p-importer@%i.service
|
||||
Before=%p-discovery@%i.service
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
ExecStartPre=-/usr/bin/docker kill %p-%i
|
||||
ExecStartPre=-/usr/bin/docker rm %p-%i
|
||||
ExecStart=/usr/bin/docker run \
|
||||
--name %p-%i \
|
||||
--link mysql-%i:db \
|
||||
-v /data/domains/%i/%p/known-content:/app/known-content \
|
||||
-v /data/domains/%i/%p/.htaccess:/app/.htaccess \
|
||||
--env-file /data/domains/%i/%p/.env \
|
||||
indiehosters/known
|
||||
ExecReload=/usr/bin/docker restart %p-%i
|
||||
ExecStop=/usr/bin/docker stop %p-%i
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in a new issue