diff --git a/README.md b/README.md index e69de29..03d7606 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,149 @@ +# Automator setup guide + +## 1. Clone the repo +```bash +git clone https://github.com/Lab5015/automator.git +``` + +--- + +## 2. Create a config file + +Inside the `cfg/` folder, create a configuration file corresponding to one of the following setups: +**[CERN, CIT, MIB, PKU, UVA]** + +**e.g. (`cfg/CERN.yaml`):** +```yaml +automator_path: /home/cmsdaq/DAQ/automator/ +db_path: /home/cmsdaq/DAQ/automator/runs.db +mtd_daq_path: /home/cmsdaq/DAQ/mtd_daq/ + +qaqc_url: http://pc-mtd-tb03/tray_qaqc + +pre_cmd: "" + +lyso_peaks_correlate: false +``` + +--- + +## 3. Create systemd service files + +You need to create **two service files** in `/etc/systemd/system/` to enable communication between the **reco PC** and **Serenity**. + +### `automator_processor.service` +``` +[Unit] +Description=automator processor +After=multi-user.target + +[Service] +Type=simple +User=cmsdaq +Restart=always +ExecStart=/bin/bash -c 'source ~/.bashrc; micromamba activate automator-env; cd /home/cmsdaq/DAQ/automator/ && python -u processor_demon.py -b CERN' +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +``` + +### `automator_server.service` +``` +[Unit] +Description=automator server +After=multi-user.target + +[Service] +Type=simple +User=cmsdaq +Restart=always +ExecStart=/bin/bash -c 'source ~/.bashrc; micromamba activate automator-env; cd /home/cmsdaq/DAQ/automator/ && python -u main.py -b CERN' + +[Install] +WantedBy=multi-user.target +``` + +--- + +## 4. Python environment + +In the `ExecStart` command, make sure you specify your **Python environment**. +In the examples above, we use a **micromamba environment** called `automator-env`. + +You’ll need the following Python packages: +- `fastapi` +- `sqlalchemy` +- `ruamel.yaml` +- `aiosqlite` + +**example of environment** +```bash +micromamba create -n automator-env python=3.10 +micromamba activate automator-env +pip install fastapi sqlalchemy ruamel.yaml aiosqlite +``` + +--- + +## 5. Permissions + +Ensure that both service files have the correct ownership and SELinux context. +They should show something like: + +``` +unconfined_u:object_r:systemd_unit_file_t:s0 +``` + +and **not** `home_t` or other types. +If needed, you can adjust permissions using: + +```bash +sudo chown root:root /etc/systemd/system/automator_*.service +sudo restorecon -v /etc/systemd/system/automator_*.service +``` + +--- + +## 6. Open a permanent port (for Serenity Communication) + +Depending on your OS, the procedure may vary. +For **AlmaLinux 9**, use: + +```bash +# Add the port +sudo firewall-cmd --permanent --add-port=5558/tcp + +# Reload firewall rules +sudo firewall-cmd --reload + +# Check that the port was added +sudo firewall-cmd --list-ports +``` + +--- + +## 7. Enable and start the services + +```bash +sudo systemctl daemon-reload +sudo systemctl start automator_server.service +sudo systemctl start automator_processor.service +``` + +Check their status: +```bash +sudo systemctl status automator_server.service +sudo systemctl status automator_processor.service +``` + +--- + +## 8. Access the GUI + +Once everything is set up, you can access the web interface at: + +``` +http://:5558 +``` \ No newline at end of file