mirror of
https://github.com/benbusby/farside.git
synced 2025-04-19 14:55:50 -04:00
remove check after update
This commit is contained in:
parent
28e4545f65
commit
2d5b31d61e
@ -6,6 +6,7 @@ defmodule Farside.Application do
|
||||
require Logger
|
||||
|
||||
alias Farside.LastUpdated
|
||||
alias Farside.Status
|
||||
alias Farside.Instance.Check
|
||||
alias Farside.Instance.Sync
|
||||
alias Farside.Http
|
||||
@ -40,6 +41,7 @@ defmodule Farside.Application do
|
||||
]
|
||||
),
|
||||
{LastUpdated, DateTime.utc_now()},
|
||||
{Status, :wait},
|
||||
{PlugAttack.Storage.Ets, name: Farside.Throttle.Storage, clean_period: 60_000},
|
||||
{DynamicSupervisor, strategy: :one_for_one, name: :server_supervisor},
|
||||
{Registry, keys: :unique, name: :servers}
|
||||
|
@ -16,8 +16,11 @@ defmodule Farside.Instance.Check do
|
||||
def poll() do
|
||||
receive do
|
||||
after
|
||||
60_000 ->
|
||||
run()
|
||||
90_000 ->
|
||||
if(Status.value() == :waiting) do
|
||||
run()
|
||||
end
|
||||
|
||||
poll()
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,7 @@ defmodule Farside.Instance do
|
||||
require Logger
|
||||
|
||||
alias Farside.Http
|
||||
alias Farside.Status
|
||||
|
||||
@registry_name :servers
|
||||
@update_file Application.fetch_env!(:farside, :update_file) <> ".json"
|
||||
@ -59,6 +60,8 @@ defmodule Farside.Instance do
|
||||
:update,
|
||||
state
|
||||
) do
|
||||
Status.value(:checking)
|
||||
|
||||
service = :ets.lookup(String.to_atom(state.type), :default)
|
||||
|
||||
{_, service} = List.first(service)
|
||||
@ -73,6 +76,8 @@ defmodule Farside.Instance do
|
||||
|
||||
Farside.save_results(@update_file, encoded)
|
||||
|
||||
Status.value(:wait)
|
||||
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
|
@ -14,6 +14,5 @@ defmodule Farside.Instances do
|
||||
LastUpdated.value(DateTime.utc_now())
|
||||
|
||||
Farside.Instance.Supervisor.update_children()
|
||||
Farside.Instance.Supervisor.sync_empty_instances()
|
||||
end
|
||||
end
|
||||
|
15
lib/farside/status.ex
Normal file
15
lib/farside/status.ex
Normal file
@ -0,0 +1,15 @@
|
||||
defmodule Farside.Status do
|
||||
use Agent
|
||||
|
||||
def start_link(initial_value) do
|
||||
Agent.start_link(fn -> initial_value end, name: __MODULE__)
|
||||
end
|
||||
|
||||
def value do
|
||||
Agent.get(__MODULE__, & &1)
|
||||
end
|
||||
|
||||
def value(new_value) do
|
||||
Agent.update(__MODULE__, fn _ -> new_value end)
|
||||
end
|
||||
end
|
55
rel/config.exs
Normal file
55
rel/config.exs
Normal file
@ -0,0 +1,55 @@
|
||||
# Import all plugins from `rel/plugins`
|
||||
# They can then be used by adding `plugin MyPlugin` to
|
||||
# either an environment, or release definition, where
|
||||
# `MyPlugin` is the name of the plugin module.
|
||||
~w(rel plugins *.exs)
|
||||
|> Path.join()
|
||||
|> Path.wildcard()
|
||||
|> Enum.map(&Code.eval_file(&1))
|
||||
|
||||
use Distillery.Releases.Config,
|
||||
# This sets the default release built by `mix distillery.release`
|
||||
default_release: :default,
|
||||
# This sets the default environment used by `mix distillery.release`
|
||||
default_environment: Mix.env()
|
||||
|
||||
# For a full list of config options for both releases
|
||||
# and environments, visit https://hexdocs.pm/distillery/config/distillery.html
|
||||
|
||||
|
||||
# You may define one or more environments in this file,
|
||||
# an environment's settings will override those of a release
|
||||
# when building in that environment, this combination of release
|
||||
# and environment configuration is called a profile
|
||||
|
||||
environment :dev do
|
||||
# If you are running Phoenix, you should make sure that
|
||||
# server: true is set and the code reloader is disabled,
|
||||
# even in dev mode.
|
||||
# It is recommended that you build with MIX_ENV=prod and pass
|
||||
# the --env flag to Distillery explicitly if you want to use
|
||||
# dev mode.
|
||||
set dev_mode: true
|
||||
set include_erts: false
|
||||
set cookie: :"G4?a`J[2D&bQ?b?%GpOMXbd2c$A[^%v(XvJaZd7]PzEUWnQRS`qf]3af7*:MwjI^"
|
||||
end
|
||||
|
||||
environment :prod do
|
||||
set include_erts: true
|
||||
set include_src: false
|
||||
set cookie: :"OciIWQ*Da2eKXW8Wfsl4{TH``k?|JO:c0|}x^AmZQUltc04ZD;!o($[]`58fG<1X"
|
||||
set vm_args: "rel/vm.args"
|
||||
end
|
||||
|
||||
# You may define one or more releases in this file.
|
||||
# If you have not set a default release, or selected one
|
||||
# when running `mix distillery.release`, the first release in the file
|
||||
# will be used by default
|
||||
|
||||
release :farside do
|
||||
set version: current_version(:farside)
|
||||
set applications: [
|
||||
:runtime_tools
|
||||
]
|
||||
end
|
||||
|
30
rel/vm.args
Normal file
30
rel/vm.args
Normal file
@ -0,0 +1,30 @@
|
||||
## This file provide the arguments provided to the VM at startup
|
||||
## You can find a full list of flags and their behaviours at
|
||||
## http://erlang.org/doc/man/erl.html
|
||||
|
||||
## Name of the node
|
||||
-name <%= release_name %>@127.0.0.1
|
||||
|
||||
## Cookie for distributed erlang
|
||||
-setcookie <%= release.profile.cookie %>
|
||||
|
||||
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
|
||||
## (Disabled by default..use with caution!)
|
||||
##-heart
|
||||
|
||||
## Enable kernel poll and a few async threads
|
||||
##+K true
|
||||
##+A 5
|
||||
## For OTP21+, the +A flag is not used anymore,
|
||||
## +SDio replace it to use dirty schedulers
|
||||
##+SDio 5
|
||||
|
||||
## Increase number of concurrent ports/sockets
|
||||
##-env ERL_MAX_PORTS 4096
|
||||
|
||||
## Tweak GC to run more often
|
||||
##-env ERL_FULLSWEEP_AFTER 10
|
||||
|
||||
# Enable SMP automatically based on availability
|
||||
# On OTP21+, this is not needed anymore.
|
||||
-smp auto
|
Loading…
x
Reference in New Issue
Block a user