mirror of
https://github.com/benbusby/farside.git
synced 2025-03-15 19:56:04 -04:00

Although the current list of queries is only 2 elements ("time" and "weather"), this allows searches for Whoogle and Searx to be slightly more random, and potentially avoid any issues with their parent engine rate limiting them.
23 lines
533 B
Elixir
23 lines
533 B
Elixir
defmodule Farside.Server do
|
|
use GenServer
|
|
import Crontab.CronExpression
|
|
|
|
def init(init_arg) do
|
|
{:ok, init_arg}
|
|
end
|
|
|
|
def start_link(arg) do
|
|
if System.get_env("FARSIDE_TEST") do
|
|
IO.puts("Skipping sync job setup...")
|
|
else
|
|
Farside.Scheduler.new_job()
|
|
|> Quantum.Job.set_name(:sync)
|
|
|> Quantum.Job.set_schedule(~e[*/5 * * * *])
|
|
|> Quantum.Job.set_task(fn -> Farside.Instances.sync() end)
|
|
|> Farside.Scheduler.add_job()
|
|
end
|
|
|
|
GenServer.start_link(__MODULE__, arg)
|
|
end
|
|
end
|