Mix tasks aren't usable from the prod release image — `/app/bin/towerops`
ships without `mix`, and `Mix.shell()` raises at runtime. Move the work
to `Towerops.Maintenance.FixMikrotikTemperatureScaling` (plain module
with `run/0`, IO.puts + Logger.info) and keep the Mix.Task as a thin
dev-only delegator.
Run in prod via:
/app/bin/towerops eval 'Towerops.Maintenance.FixMikrotikTemperatureScaling.run()'
26 lines
774 B
Elixir
26 lines
774 B
Elixir
defmodule Mix.Tasks.Towerops.FixMikrotikTemperatureScaling do
|
|
@shortdoc "Renormalise stored temperature sensor readings using SensorScale"
|
|
|
|
@moduledoc """
|
|
Dev-only convenience wrapper. Delegates to
|
|
`Towerops.Maintenance.FixMikrotikTemperatureScaling.run/0` so you can
|
|
run the backfill from a local checkout via:
|
|
|
|
mix towerops.fix_mikrotik_temperature_scaling
|
|
|
|
In prod the release has no `mix` binary — invoke the plain module
|
|
directly:
|
|
|
|
/app/bin/towerops eval 'Towerops.Maintenance.FixMikrotikTemperatureScaling.run()'
|
|
"""
|
|
|
|
use Mix.Task
|
|
|
|
alias Towerops.Maintenance.FixMikrotikTemperatureScaling
|
|
|
|
@impl Mix.Task
|
|
def run(_argv) do
|
|
{:ok, _} = Application.ensure_all_started(:towerops)
|
|
FixMikrotikTemperatureScaling.run()
|
|
end
|
|
end
|