flyedge.service runs /opt/fly/current/fly-edge After= and Requires= flysim.service, with its metrics on loopback :9102 and a ConditionPathExists so a release without the binary leaves it inactive. It is in no target and 07-enable.sh does not enable it; the header has the switch and the way back. build-flysim.sh also builds fly-edge beside the flysim binary and package-release.sh ships it when present. 05-deploy.sh writes FLY_FEED_VIA (default direct) into fly.env, flysim.service names FLY_BUS_DIR=/run/fly/bus and tmpfiles creates it. Watchdog check 2 reads the feed counters from whoever serves the feed: flyedge when fly.env says bus. lint.sh holds all of that, and drives check 2's choice against a fixture.
56 lines
2.7 KiB
Desktop File
56 lines
2.7 KiB
Desktop File
# infra/units/flyedge.service — pushed to /etc/systemd/system/flyedge.service.
|
|
#
|
|
# The feed WebSocket served from flysim's feed bus (docs/design/flybus.md,
|
|
# "Feed over the bus"; services/flysim/crates/fly-edge). DISABLED BY DEFAULT:
|
|
# it is in no target's Wants=/Requires= and 07-enable.sh does not enable it.
|
|
# With FLY_FEED_VIA=direct (the default, written into /etc/fly/fly.env by
|
|
# 05-deploy.sh) flysim binds 127.0.0.1:7400 itself and this unit has nothing
|
|
# to do. To move the feed onto the bus on one container:
|
|
#
|
|
# 1. FLY_FEED_VIA=bus in the env file, then 05-deploy.sh (rewrites fly.env);
|
|
# 2. systemctl enable --now flyedge.service; systemctl restart flysim.service
|
|
# (flysim stops binding :7400, the edge binds it once the first snapshot
|
|
# is on the bus);
|
|
# 3. nothing for the watchdog: check 2 reads FLY_FEED_VIA from fly.env and
|
|
# follows the feed counters to this unit's loopback /metrics.
|
|
#
|
|
# Back: FLY_FEED_VIA=direct, deploy, systemctl disable --now flyedge.service,
|
|
# restart flysim.
|
|
#
|
|
# Ordering (docs/design/flybus.md, amendment "Feed store lifecycle"): flysim
|
|
# owns the router and its store under /run/fly/bus, so it starts first and
|
|
# the edge follows it. Requires= makes an explicit stop or restart of flysim
|
|
# (the unstick rule's `systemctl restart flysim.service` included) stop or
|
|
# restart the edge with it. A crash-restart of flysim is covered by the edge
|
|
# itself: it drops its clients, unbinds :7400 and reconnects every 500 ms,
|
|
# so nothing here has to be restarted by hand. The edge holds no state; the
|
|
# store is flysim's and a new router removes the previous one's directory.
|
|
[Unit]
|
|
Description=flyedge: the feed WebSocket served from flysim's feed bus
|
|
After=flysim.service
|
|
Requires=flysim.service
|
|
# A release that predates fly-edge has no binary; stay cleanly inactive
|
|
# rather than restart-looping (the flybridge.service header explains why a
|
|
# Condition, not a start limit).
|
|
ConditionPathExists=/opt/fly/current/fly-edge
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=fly
|
|
# FLY_FEED_VIA, FLY_BUS_DIR and the rest of flysim's configuration: the edge
|
|
# reads the same file so the two cannot disagree about the port or the bus.
|
|
EnvironmentFile=/etc/fly/fly.env
|
|
Environment=FLY_FEED_BIND=127.0.0.1:7400
|
|
Environment=FLY_BUS_DIR=/run/fly/bus
|
|
# Its own read-only /metrics and /healthz, for watchdog check 2 in bus mode.
|
|
# Loopback only: nothing off the container needs the edge's counters.
|
|
Environment=FLY_EDGE_METRICS_ADDR=127.0.0.1:9102
|
|
ExecStart=/opt/fly/current/fly-edge
|
|
Restart=always
|
|
RestartSec=2
|
|
# A few snapshots in flight and a WebSocket per client; the store itself is
|
|
# flysim's (tmpfs, bounded by feedbus::limits at 32 MiB).
|
|
MemoryMax=256M
|
|
|
|
[Install]
|
|
WantedBy=fly.target
|