Reindex farmware if bot_state crashes
parent
4f8dcbbe32
commit
ec1b8c2412
|
@ -1,11 +1,13 @@
|
|||
# Changelog
|
||||
# 6.4.7
|
||||
* Fix DNS server config for self hosters.
|
||||
* Fix DNS server config for self hosters.
|
||||
* Add new field to `informational_settings`: `currently_on_beta`.
|
||||
* Reindex farmware on bot_state crash.
|
||||
|
||||
# 6.4.6
|
||||
* Add new RPC to reinitialize Firmware
|
||||
* Tweak PinBinding debounce timeout.
|
||||
* Update Linux system layer to fix sound
|
||||
* Update Linux system layer to fix sound.
|
||||
|
||||
# 6.4.5
|
||||
* Fix Firmware syncing applying _every_ setting.
|
||||
|
|
|
@ -162,7 +162,14 @@ defmodule Farmbot.BotState do
|
|||
user_env: user_env
|
||||
]
|
||||
initial_state = struct(__MODULE__, state_opts)
|
||||
info_settings = %{initial_state.informational_settings | node_name: node()}
|
||||
info_settings = %{
|
||||
initial_state.informational_settings |
|
||||
node_name: node(),
|
||||
currently_on_beta: settings["currently_on_beta"]
|
||||
}
|
||||
if Process.whereis(Farmbot.Farmware.Supervisor) do
|
||||
send(self(), :reindex_farmware)
|
||||
end
|
||||
state = %{initial_state | informational_settings: info_settings}
|
||||
gen_stage_opts = [
|
||||
subscribe_to: [Firmware, ConfigStorage.Dispatcher, Farmbot.PinBinding.Manager],
|
||||
|
@ -177,6 +184,11 @@ defmodule Farmbot.BotState do
|
|||
{:noreply, [state], state}
|
||||
end
|
||||
|
||||
def handle_info(:reindex_farmware, state) do
|
||||
spawn Farmbot.Farmware.Supervisor, :reindex, []
|
||||
{:noreply, [], state}
|
||||
end
|
||||
|
||||
def handle_call({:report_soc_temp, temp}, _from, state) do
|
||||
new_info_settings = %{state.informational_settings | soc_temp: temp}
|
||||
state = %{state | informational_settings: new_info_settings}
|
||||
|
@ -364,6 +376,7 @@ defmodule Farmbot.BotState do
|
|||
cache_bust: 0,
|
||||
soc_temp: 0,
|
||||
wifi_level: nil,
|
||||
currently_on_beta: nil,
|
||||
},
|
||||
location_data: %{
|
||||
position: %{x: nil, y: nil, z: nil},
|
||||
|
|
|
@ -3,6 +3,17 @@ defmodule Farmbot.Farmware.Supervisor do
|
|||
use Supervisor
|
||||
alias Farmbot.Farmware.Installer.Repository.SyncTask
|
||||
|
||||
def reindex do
|
||||
path = Farmbot.Farmware.Installer.install_root_path()
|
||||
|
||||
if path && File.exists?(path) do
|
||||
for fwname <- File.ls!(path) do
|
||||
{:ok, fw} = Farmbot.Farmware.lookup(fwname)
|
||||
Farmbot.BotState.register_farmware(fw)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@doc false
|
||||
def start_link do
|
||||
Supervisor.start_link(__MODULE__, [], name: __MODULE__)
|
||||
|
|
|
@ -98,6 +98,7 @@ defmodule Farmbot.System do
|
|||
end
|
||||
|
||||
defp write_file(reason) do
|
||||
IO.puts "Farmbot powering down: #{reason}"
|
||||
file = Path.join(@data_path, "last_shutdown_reason")
|
||||
File.write!(file, reason)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue