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.
This commit is contained in:
Ben Busby 2021-10-22 18:07:59 -06:00
parent 4949ae22bb
commit edcab37c7d
No known key found for this signature in database
GPG Key ID: 339B7B7EB5333D14
2 changed files with 11 additions and 0 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@ erl_crash.dump
*.beam
/config/*.secret.exs
.elixir_ls/
# Ignore results from update script
.update-result*

View File

@ -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")