Skip to content

Quit more gracefully if configuration is incomplete

Dinyar Rabady requested to merge chore/check_config into master

We do a quick check to make sure that all fields have both a key and value now. If not, we quit and don't restart via the script. Also limited the number of service restarts to 5 in a 100 second window to avoid systemd restarting us too often when it's hopeless.

Tested at P5 with the (now) default config file and get:

; systemctl status runSCdaq.service
● runSCdaq.service - Wrapper script to run scdaq
   Loaded: loaded (/usr/lib/systemd/system/runSCdaq.service; disabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sat 2022-09-24 14:39:02 CEST; 1min 25s ago
  Process: 1438 ExecStart=/opt/scdaq/scripts/run.sh (code=exited, status=1/FAILURE)
 Main PID: 1438 (code=exited, status=1/FAILURE)

after five retries, as expected.

In the log I see

Sep 24 14:38:57 cmd-scouting-ctrlhub run.sh[1438]: Starting scdaq...
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: DEBUG   main: scdaq started with conffile:   /etc/scdaq/scdaq.conf
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: ERROR   config::config: Configuration entry processor_type has no value!
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: ERROR   config::config: Configuration entry output_filename_prefix has no value!
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: ERROR   config::config: Configuration entry output_filename_base has no value!
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key NOrbitsPerDMAPacket value 20
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key bitFileName value micron_bitfile_path
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key dma_dev value /dev/xdma0_c2h_0
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key dma_number_of_packet_buffers value 1000
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key dma_packet_buffer_size value 1048576
Sep 24 14:38:57 cmd-scouting-ctrlhub systemd[1]: Can't convert PID files /var/log/scdaq/pid O_PATH file descriptor to proper file descriptor: Is a directory
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key doZS value yes
Sep 24 14:38:57 cmd-scouting-ctrlhub systemd[1]: runSCdaq.service: main process exited, code=exited, status=1/FAILURE
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key elastic_url value http://something.somewhere
Sep 24 14:38:57 cmd-scouting-ctrlhub systemd[1]: Unit runSCdaq.service entered failed state.
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key enable_elastic_processor value no
Sep 24 14:38:57 cmd-scouting-ctrlhub systemd[1]: runSCdaq.service failed.
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key enable_stream_processor value yes
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key input value wzdma
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key input_file value testdata.bin
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key loadBitFile value yes
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key max_file_size value 8589934592
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key nOrbitsPerFile value 1000000
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key output_filename_base value
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key output_filename_prefix value
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key output_force_write value no
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key packets_per_report value 200000
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key port value 8000
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key prescale_factor value 1
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key processor_type value
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key pt_cut value 7
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key quality_cut value 12
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key threads value 8
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: INFO    config::print: key verbosity value 0
Sep 24 14:38:57 cmd-scouting-ctrlhub scdaq[1445]: ERROR   main: Configuration invalid! Bailing out.

which has the systemd messages interspersed with the SCDAQ output unfortunately, but our logging problem is something to be tackled in a separate MR I think.

Belongs to #15 (closed).

Edited by Dinyar Rabady

Merge request reports