@@ -20,6 +20,7 @@ use std::{
2020use fs2:: FileExt ;
2121use reqwest:: blocking:: Client ;
2222use serde:: { Deserialize , Serialize , de:: Error as _} ;
23+ use serde_xml_rs;
2324use serde_yaml;
2425use sysinfo:: { ProcessesToUpdate , System } ;
2526use tracing:: { debug, error, info, trace, warn} ;
@@ -179,7 +180,7 @@ impl PidFile {
179180 return Ok ( Self :: default ( ) ) ;
180181 }
181182 let contents = fs:: read_to_string ( path) ?;
182- let pid_data = serde_json :: from_str :: < Self > ( & contents) ?;
183+ let pid_data = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
183184 Ok ( pid_data)
184185 }
185186
@@ -199,7 +200,7 @@ impl PidFile {
199200
200201 let path = Self :: path ( ) ;
201202 let contents = fs:: read_to_string ( & path) ?;
202- let pid_data = serde_json :: from_str :: < Self > ( & contents) ?;
203+ let pid_data = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
203204 Ok ( pid_data)
204205 }
205206
@@ -209,7 +210,7 @@ impl PidFile {
209210
210211 let path = Self :: path ( ) ;
211212 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
212- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
213+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
213214 Ok ( ( ) )
214215 }
215216
@@ -230,7 +231,7 @@ impl PidFile {
230231 let path = Self :: path ( ) ;
231232 if path. exists ( ) {
232233 let contents = fs:: read_to_string ( & path) ?;
233- * self = serde_json :: from_str :: < Self > ( & contents) ?;
234+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
234235 }
235236
236237 self . services . insert ( service. to_string ( ) , pid) ;
@@ -239,7 +240,7 @@ impl PidFile {
239240 }
240241
241242 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
242- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
243+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
243244 Ok ( ( ) )
244245 }
245246
@@ -250,15 +251,15 @@ impl PidFile {
250251 let path = Self :: path ( ) ;
251252 if path. exists ( ) {
252253 let contents = fs:: read_to_string ( & path) ?;
253- * self = serde_json :: from_str :: < Self > ( & contents) ?;
254+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
254255 }
255256
256257 if self . services . remove ( service) . is_none ( ) {
257258 return Err ( PidFileError :: ServiceNotFound ) ;
258259 }
259260
260261 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
261- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
262+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
262263 Ok ( ( ) )
263264 }
264265
@@ -269,15 +270,15 @@ impl PidFile {
269270 let path = Self :: path ( ) ;
270271 if path. exists ( ) {
271272 let contents = fs:: read_to_string ( & path) ?;
272- * self = serde_json :: from_str :: < Self > ( & contents) ?;
273+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
273274 }
274275
275276 if self . services . remove ( service) . is_none ( ) {
276277 return Err ( PidFileError :: ServiceNotFound ) ;
277278 }
278279 self . service_groups . remove ( service) ;
279280 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
280- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
281+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
281282 Ok ( ( ) )
282283 }
283284
@@ -296,7 +297,7 @@ impl PidFile {
296297 let path = Self :: path ( ) ;
297298 if path. exists ( ) {
298299 let contents = fs:: read_to_string ( & path) ?;
299- * self = serde_json :: from_str :: < Self > ( & contents) ?;
300+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
300301 }
301302
302303 let child_pid = metadata. pid ;
@@ -312,7 +313,7 @@ impl PidFile {
312313 self . spawn_metadata . insert ( child_pid, metadata) ;
313314
314315 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
315- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
316+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
316317 Ok ( ( ) )
317318 }
318319
@@ -326,15 +327,15 @@ impl PidFile {
326327 let path = Self :: path ( ) ;
327328 if path. exists ( ) {
328329 let contents = fs:: read_to_string ( & path) ?;
329- * self = serde_json :: from_str :: < Self > ( & contents) ?;
330+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
330331 }
331332
332333 if let Some ( metadata) = self . spawn_metadata . get_mut ( & child_pid) {
333334 metadata. last_exit = Some ( exit. clone ( ) ) ;
334335 }
335336
336337 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
337- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
338+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
338339 Ok ( ( ) )
339340 }
340341
@@ -345,7 +346,7 @@ impl PidFile {
345346 let path = Self :: path ( ) ;
346347 if path. exists ( ) {
347348 let contents = fs:: read_to_string ( & path) ?;
348- * self = serde_json :: from_str :: < Self > ( & contents) ?;
349+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
349350 }
350351
351352 if let Some ( parent_pid) = self . parent_map . remove ( & child_pid)
@@ -360,7 +361,7 @@ impl PidFile {
360361 self . spawn_metadata . remove ( & child_pid) ;
361362
362363 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
363- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
364+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
364365 Ok ( ( ) )
365366 }
366367
@@ -373,13 +374,13 @@ impl PidFile {
373374 let path = Self :: path ( ) ;
374375 if path. exists ( ) {
375376 let contents = fs:: read_to_string ( & path) ?;
376- * self = serde_json :: from_str :: < Self > ( & contents) ?;
377+ * self = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
377378 }
378379
379380 let removed = self . remove_spawn_subtree_in_memory ( root_pid) ;
380381
381382 fs:: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
382- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
383+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
383384
384385 Ok ( removed)
385386 }
@@ -616,7 +617,7 @@ impl ServiceStateFile {
616617 }
617618
618619 let contents = fs:: read_to_string ( path) ?;
619- let state = serde_json :: from_str :: < Self > ( & contents) ?;
620+ let state = serde_xml_rs :: from_str :: < Self > ( & contents) ?;
620621 Ok ( state)
621622 }
622623
@@ -626,7 +627,7 @@ impl ServiceStateFile {
626627 if let Some ( parent) = path. parent ( ) {
627628 fs:: create_dir_all ( parent) ?;
628629 }
629- fs:: write ( & path, serde_json :: to_string_pretty ( self ) ?) ?;
630+ fs:: write ( & path, serde_xml_rs :: to_string ( self ) ?) ?;
630631 Ok ( ( ) )
631632 }
632633
@@ -2573,13 +2574,14 @@ impl Daemon {
25732574 ) ) )
25742575 } ) ?;
25752576
2576- let state: BlueGreenState = serde_json:: from_str ( & content) . map_err ( |source| {
2577- ProcessManagerError :: ConfigParseError ( serde_yaml:: Error :: custom ( format ! (
2578- "Failed parsing blue/green state '{}': {}" ,
2579- path. display( ) ,
2580- source
2581- ) ) )
2582- } ) ?;
2577+ let state: BlueGreenState =
2578+ serde_xml_rs:: from_str ( & content) . map_err ( |source| {
2579+ ProcessManagerError :: ConfigParseError ( serde_yaml:: Error :: custom ( format ! (
2580+ "Failed parsing blue/green state '{}': {}" ,
2581+ path. display( ) ,
2582+ source
2583+ ) ) )
2584+ } ) ?;
25832585
25842586 if state. active_slot_index > 1 {
25852587 return Err ( Self :: config_error ( format ! (
@@ -2602,7 +2604,7 @@ impl Daemon {
26022604 if let Some ( parent) = path. parent ( ) {
26032605 fs:: create_dir_all ( parent) ?;
26042606 }
2605- let content = serde_json :: to_string ( & BlueGreenState { active_slot_index } )
2607+ let content = serde_xml_rs :: to_string ( & BlueGreenState { active_slot_index } )
26062608 . map_err ( |source| {
26072609 ProcessManagerError :: ConfigParseError ( serde_yaml:: Error :: custom (
26082610 source. to_string ( ) ,
0 commit comments