From 7cac51a995f687c4813e8558f3d7fad564a2a084 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 7 Jan 2022 17:16:20 +0300 Subject: feat(ops/auto-deploy): Support emergency stops via stop file Adds a feature to emergency-stop deploys by simply running `touch /var/lib/auto-deploy/stop`. This can be useful in some situations, especially if there is a process that reconciles service state (so that e.g. stopping the unit's timer would be undone). Change-Id: I233dfac365a578bfa4110eb605b50be079974ba4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4827 Autosubmit: tazjin Tested-by: BuildkiteCI Reviewed-by: grfn Reviewed-by: wpcarro --- ops/modules/auto-deploy.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ops/modules/auto-deploy.nix') diff --git a/ops/modules/auto-deploy.nix b/ops/modules/auto-deploy.nix index a90300d42c..83a8273562 100644 --- a/ops/modules/auto-deploy.nix +++ b/ops/modules/auto-deploy.nix @@ -1,5 +1,9 @@ # Defines a service for automatically and periodically calling depot's # rebuild-system on a NixOS machine. +# +# Deploys can be stopped in emergency situations by creating an empty +# file called `stop` in the state directory of the auto-deploy service +# (typically /var/lib/auto-deploy). { depot, config, lib, pkgs, ... }: let @@ -15,6 +19,11 @@ let exit 1 fi + if [[ -f $STATE_DIRECTORY/stop ]]; then + echo "stop file exists in $STATE_DIRECTORY, not deploying!" >&2 + exit 1 + fi + readonly depot=$STATE_DIRECTORY/depot.git readonly deploy=$STATE_DIRECTORY/deploy readonly git="git -C $depot" -- cgit 1.4.1