From 7693a6b0633c3eee5d717662df72b62463d6f2d1 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Mon, 17 Jul 2023 17:46:39 -0600 Subject: [PATCH] Add env var for toggling cron task on/off FARSIDE_CRON allows turning on/off the scheduled instance availability check that occurs every 5 minutes by setting the variable to 1 (on) or 0 (off). The default behavior is "on". --- README.md | 8 ++++++-- lib/farside/server.ex | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ff58f43..845283e 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ goes against what Farside is trying to solve. Use at your own discretion. To run Farside without compiling, you can perform the following steps: - Install dependencies: `mix deps.get` -- Initialize db contents: `mix run -e Farside.Instances.sync` +- Initialize db contents: `FARSIDE_CRON=0 mix run -e Farside.Instances.sync` - Run Farside: `mix run --no-halt` - Uses localhost:4001 @@ -233,7 +233,11 @@ farside FARSIDE_SERVICES_JSON - The "services" JSON file to use for selecting instances (default: `services.json`) + The JSON file to use for selecting instances (default: `services.json`) + + + FARSIDE_CRON + Set to 0 to deactivate the scheduled instance availability check (default on). diff --git a/lib/farside/server.ex b/lib/farside/server.ex index 61aff40..cdb6682 100644 --- a/lib/farside/server.ex +++ b/lib/farside/server.ex @@ -7,7 +7,10 @@ defmodule Farside.Server do end def start_link(arg) do - if System.get_env("FARSIDE_TEST") do + test = System.get_env("FARSIDE_TEST") + cron = System.get_env("FARSIDE_CRON") + + if test == "1" || cron == "0" do IO.puts("Skipping sync job setup...") else Farside.Scheduler.new_job()