about summary refs log tree commit diff
path: root/ops
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-01-07T14·16+0300
committertazjin <tazjin@tvl.su>2022-01-07T17·17+0000
commit7cac51a995f687c4813e8558f3d7fad564a2a084 (patch)
tree6cf672f1173eb64b2fcf6f8d59abf0e2c4cb8bbb /ops
parentb8e011f7927e63383b3f22ae32eb53fc86449315 (diff)
feat(ops/auto-deploy): Support emergency stops via stop file r/3526
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 <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'ops')
-rw-r--r--ops/modules/auto-deploy.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/ops/modules/auto-deploy.nix b/ops/modules/auto-deploy.nix
index a90300d42c68..83a8273562f6 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"