summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Busby <noreply+git@benbusby.com>2021-10-22 18:07:59 -0600
committerBen Busby <noreply+git@benbusby.com>2021-10-22 18:07:59 -0600
commitedcab37c7d48259c7cf7969f95cb4efdbd728c93 (patch)
treef1870587138e1519387661ccec4465e02eed1a24
parent4949ae22bb2fd1b81cdfbbe21468015fb229b553 (diff)
downloadfarside-edcab37c7d48259c7cf7969f95cb4efdbd728c93.tar.gz
Write results of update script to file for debugging
The update script now writes the available instances to a .update-results* file (where previous runs have "-prev" appended to the file name). This helps to see how instance availability changes between runs of the script when debugging overall functionality of the app.
-rw-r--r--.gitignore3
-rw-r--r--update.exs8
2 files changed, 11 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index b263cd1..0126d78 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,6 @@ erl_crash.dump
*.beam
/config/*.secret.exs
.elixir_ls/
+
+# Ignore results from update script
+.update-result*
diff --git a/update.exs b/update.exs
index dad22ec..65110f6 100644
--- a/update.exs
+++ b/update.exs
@@ -33,6 +33,7 @@ defmodule Instances do
end)
add_to_redis(conn, service, result)
+ log_results(service.type, result)
end
end
@@ -65,6 +66,13 @@ defmodule Instances do
])
end
end
+
+ def log_results(service_name, results) do
+ {:ok, file} = File.open(".update-results", [:append, {:delayed_write, 100, 20}])
+ IO.write(file, service_name <> ": " <> inspect(results) <> "\n")
+ File.close(file)
+ end
end
+File.rename(".update-results", ".update-results-prev")
Instances.update("services.json")