Skip to content

Commit

Permalink
multi-node setup should work now; cleaner bootstrapping; `supervisorc…
Browse files Browse the repository at this point in the history
…tl status` work in any dir; quiet shutdown
  • Loading branch information
traceypooh committed Mar 2, 2024
1 parent 6a95947 commit 13626d1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ WORKDIR /app
COPY . .

RUN cp etc/supervisord.conf /etc/supervisor/conf.d/ && \
# make it so `supervisorctl status` can work in any dir, esp. /app/:
rm etc/supervisord.conf && \
ln -s /app/etc/Caddyfile.ctmpl /etc/ && \
cat etc/nomad.hcl >> ${NOMAD_HCL} && \
cat etc/consul.hcl >> ${CONSUL_HCL} && \
Expand Down
18 changes: 15 additions & 3 deletions bin/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/zsh -eu

if [ ! -e $CONFIG ]; then
# create a new docker image with the bootstrapped version of your cluster
touch $CONFIG
/app/bin/spinner "Bootstrapping your hind cluster..." /app/bin/bootstrap.sh
/app/bin/spinner 'cleanly shutting down' /app/bin/shutdown.sh
/app/bin/spinner 'committing bootstrapped image' podman commit hind-init hind
exit 0
fi

export FIRST=${FIRST:-""}

echo "name = \"$(hostname -s)\"" >> $NOMAD_HCL
echo "node_name = \"$(hostname -s)\"" >> $CONSUL_HCL
Expand Down Expand Up @@ -74,7 +84,6 @@ else
[ "$?" = "0" ] && break
done

touch $CONFIG
fi


Expand Down Expand Up @@ -118,5 +127,8 @@ echo
echo
consul members
echo
nomad server members
echo

if [ ! $FIRST ]; then
nomad server members
echo
fi
21 changes: 5 additions & 16 deletions bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
#!/bin/zsh -eu

export FIRST=${FIRST:-""}
# set for `nomad run` of jobs with `podman` driver
podman system service -t 0 & # xxx
# test
# sudo curl -v -s --unix-socket /run/podman/podman.sock http://d/v1.0.0/libpod/info

if [ ! -e $CONFIG ]; then
# create a new docker image with the bootstrapped version of your cluster
./bin/spinner "Bootstrapping your hind cluster..." /app/bin/bootstrap.sh
./bin/spinner 'cleanly shutting down' /app/bin/shutdown.sh
./bin/spinner 'committing bootstrapped image' podman commit hind-init hind

else

# set for `nomad run` of jobs with `podman` driver
podman system service -t 0 & # xxx
# test
# sudo curl -v -s --unix-socket /run/podman/podman.sock http://d/v1.0.0/libpod/info

exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
fi
exec /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
27 changes: 14 additions & 13 deletions bin/shutdown.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/bin/zsh -eu

# cleanly shutdown so we dont have a dangling supervisord socket at `podman commit` time
# cleanly & quietly shutdown so we dont have a dangling supervisord socket at `podman commit` time
(
cd /etc/supervisor
supervisorctl stop nomad
supervisorctl stop consul
supervisorctl stop consul-template
supervisorctl stop caddy-restarter
supervisorctl shutdown
sleep 5

cd /etc/supervisor
supervisorctl stop nomad
supervisorctl stop consul
supervisorctl stop consul-template
supervisorctl stop caddy-restarter
supervisorctl shutdown
sleep 5

# we want to persist https certs
mkdir -p /root/.local/share
rm -rf /root/.local/share/caddy
ln -s /pv/CERTS /root/.local/share/caddy
# we want to persist https certs
mkdir -p /root/.local/share
rm -rf /root/.local/share/caddy
ln -s /pv/CERTS /root/.local/share/caddy
) >/dev/null 2>&1
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ podman -v || exit 1
podman run --net=host --privileged --cgroupns=host \
-v /var/lib/containers:/var/lib/containers \
-e FQDN -e HOST_UNAME \
--rm --name hind-init --pull=always "$@" ghcr.io/internetarchive/hind:podman
--rm --name hind-init --pull=always "$@" ghcr.io/internetarchive/hind:podman /app/bin/bootstrap.sh
# xxx :main -- also change GH Pages to build from main branch when merge podman => main
)

Expand Down

0 comments on commit 13626d1

Please sign in to comment.