Skip to content

Commit f4fd91d

Browse files
committed
Remove pratial support for hot reload.
Since most operations easily recover from a server restart hot reload is not actually needed, also it is only partially supported so it is almost never used. Hot reload also increase code complexity, thus we are removing it.
1 parent a6b8dae commit f4fd91d

5 files changed

Lines changed: 10 additions & 40 deletions

File tree

pixie-server/src/dnsmasq.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,9 @@ fn get_hosts(
114114

115115
pub async fn main(state: Arc<State>) -> Result<()> {
116116
let mut units_rx = state.subscribe_units();
117-
let mut hostmap_rx = state.subscribe_hostmap();
118117

119118
write_config(&state).await?;
120-
let mut hosts = get_hosts(
121-
&hostmap_rx.borrow_and_update(),
122-
&units_rx.borrow_and_update(),
123-
);
119+
let mut hosts = get_hosts(&state.hostmap, &units_rx.borrow_and_update());
124120
write_hosts(&state, &hosts).await?;
125121

126122
let dnsmasq = DnsmasqHandle {
@@ -138,14 +134,10 @@ pub async fn main(state: Arc<State>) -> Result<()> {
138134
loop {
139135
tokio::select! {
140136
ret = units_rx.changed() => ret.unwrap(),
141-
ret = hostmap_rx.changed() => ret.unwrap(),
142137
_ = state.cancel_token.cancelled() => break,
143138
}
144139

145-
let hosts2 = get_hosts(
146-
&hostmap_rx.borrow_and_update(),
147-
&units_rx.borrow_and_update(),
148-
);
140+
let hosts2 = get_hosts(&state.hostmap, &units_rx.borrow_and_update());
149141
if hosts != hosts2 {
150142
hosts = hosts2;
151143
write_hosts(&state, &hosts).await?;

pixie-server/src/http.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,18 @@ async fn gc(extract::State(state): extract::State<Arc<State>>) -> impl IntoRespo
156156
///
157157
/// Stream of json-formatted events on changes to the database.
158158
async fn status(extract::State(state): extract::State<Arc<State>>) -> impl IntoResponse {
159-
let initial_messages = [StatusUpdate::Config(state.config.clone())];
159+
let initial_messages = [
160+
StatusUpdate::Config(state.config.clone()),
161+
StatusUpdate::HostMap(state.hostmap.clone()),
162+
];
160163

161164
let units_rx = WatchStream::new(state.subscribe_units());
162165
let image_rx = WatchStream::new(state.subscribe_images());
163-
let hostmap_rx = WatchStream::new(state.subscribe_hostmap());
164166

165167
let messages = futures::stream::iter(initial_messages)
166168
.chain(futures::stream::select(
167-
futures::stream::select(
168-
image_rx.map(StatusUpdate::ImagesStats),
169-
units_rx.map(StatusUpdate::Units),
170-
),
171-
hostmap_rx.map(StatusUpdate::HostMap),
169+
image_rx.map(StatusUpdate::ImagesStats),
170+
units_rx.map(StatusUpdate::Units),
172171
))
173172
.take_until(state.cancel_token.clone().cancelled_owned());
174173
let lines = messages.map(|msg| serde_json::to_string(&msg).map(|x| x + "\n"));

pixie-server/src/main.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,6 @@ async fn main() -> Result<()> {
143143
}
144144
});
145145

146-
let state2 = state.clone();
147-
tokio::spawn(async move {
148-
let mut sighup = tokio::signal::unix::signal(SignalKind::hangup())
149-
.expect("failed to register SIGHUP handler");
150-
while let Some(()) = sighup.recv().await {
151-
state2.reload().unwrap();
152-
}
153-
});
154-
155146
async fn flatten(task: JoinHandle<Result<()>>) -> Result<()> {
156147
task.await??;
157148
Ok(())

pixie-server/src/state/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub struct State {
9494
/// The config parsed from the config file.
9595
pub config: Config,
9696
/// The hostmap built from the hostmap file.
97-
hostmap: watch::Sender<HashMap<Ipv4Addr, String>>,
97+
pub hostmap: HashMap<Ipv4Addr, String>,
9898

9999
units: watch::Sender<Vec<Unit>>,
100100
registration_hint: Mutex<Option<RegistrationInfo>>,
@@ -216,24 +216,14 @@ impl State {
216216
storage_dir,
217217
run_dir,
218218
config,
219-
hostmap: watch::Sender::new(hostmap),
219+
hostmap,
220220
units,
221221
registration_hint: Mutex::new(None),
222222
images_stats: watch::Sender::new(images_stats),
223223
chunks_stats: Mutex::new(chunks_stats),
224224
cancel_token,
225225
})
226226
}
227-
228-
pub fn reload(&self) -> Result<()> {
229-
let hostmap = build_hostmap(self.config.hosts.hostsfile.as_deref())?;
230-
self.hostmap.send_replace(hostmap);
231-
Ok(())
232-
}
233-
234-
pub fn subscribe_hostmap(&self) -> watch::Receiver<HashMap<Ipv4Addr, String>> {
235-
self.hostmap.subscribe()
236-
}
237227
}
238228

239229
impl Drop for State {

pixie.service

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ Group=root
1010
ExecStart=/usr/local/bin/pixie-server -s /var/local/lib/pixie
1111
Environment=RUST_LOG=info
1212
WorkingDirectory=/var/local/lib/pixie
13-
ExecReload=kill -HUP $MAINPID
1413
Restart=always
1514
RestartSec=30
1615
LimitNOFILE=65536
1716

18-
1917
[Install]
2018
WantedBy=multi-user.target

0 commit comments

Comments
 (0)