Skip to content

Commit 9787cd7

Browse files
Merge pull request #16 from mantidproject/expand_docs
document the service scripts
2 parents e846a70 + 73ed982 commit 9787cd7

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

README.md

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Configuration and logging
2-
-------------------------
1+
Configuration
2+
-------------
33

44
The configuration is automatically read from `/etc/livereduce.conf`unless specified as a command line argument.
55
Defaults will be attempted to be determined from the environment.
@@ -10,17 +10,22 @@ A minimal configuration to specify using nightly builds of mantid installed in a
1010
"CONDA_ENV": "mantid-dev"
1111
}
1212
```
13-
For testing a configuration file can be supplied as a command line argument when running
13+
For testing, a configuration file can be supplied as a command line argument when running
1414
```shell
1515
$ python scripts/livereduce.py ./livereduce.conf
1616
```
17+
If the instrument is not defined in the configuration file,
18+
the software will ask mantid for the default instrument using
19+
`mantid.kerel.ConfigService.getInstrument()` ([docs](https://docs.mantidproject.org/nightly/api/python/mantid/kernel/ConfigServiceImpl.html#mantid.kernel.ConfigServiceImpl.getInstrument)).
20+
The default instrument is controlled in the [mantid properties files](https://docs.mantidproject.org/nightly/concepts/PropertiesFile.html)
21+
and is typically defined in `/etc/mantid.local.properties`.
1722

18-
The logfile of what was setup for running, as well as other messages, is
19-
`/var/log/SNS_applications/livereduce.log` if run as the user `snsdata`,
20-
or `livereduce.log` in the current working directory (if run from the
21-
command line).
23+
24+
Managing the service
25+
--------------------
2226

2327
If run from inside `systemctl`, use the standard commands for starting and stopping it.
28+
2429
```shell
2530
sudo systemctl start livereduce
2631
sudo systemctl stop livereduce
@@ -30,25 +35,43 @@ The status of the service can be found via
3035
```shell
3136
sudo systemctl status livereduce status
3237
```
38+
39+
Logging
40+
--------
41+
42+
The logfile of what was setup for running, as well as other messages, is
43+
`/var/log/SNS_applications/livereduce.log` if run as the user `snsdata`,
44+
or `livereduce.log` in the current working directory (if run from the
45+
command line).
46+
3347
the logs are stored in `/var/log/SNS_applications/livereduce.log` and are readable by anyone.
3448
People with extra permissions can run ``sudo journalctl -u livereduce -f`` and see all of the logs without them flushing on restart of the service.
3549
Sometimes the service refuses to restart, in that case `stop` then `start` it in separate commands.
3650

37-
If the instrument is not defined in the configuration file (default is `/etc/livereduce.conf`) the software will ask mantid for the default instrument using `mantid.kerel.ConfigService.getInstrument()` ([docs](https://docs.mantidproject.org/nightly/api/python/mantid/kernel/ConfigServiceImpl.html#mantid.kernel.ConfigServiceImpl.getInstrument)).
38-
The default instrument is controlled in the [mantid properties files](https://docs.mantidproject.org/nightly/concepts/PropertiesFile.html) and is typically defined in `/etc/mantid.local.properties`.
3951

40-
The script files that are used/looked for are
52+
Python processing scripts
53+
-------------------------
4154

42-
* `<script_dir>/reduce_<instrument>_proc.py` is the processing script
43-
(for each chunk). This is required.
44-
* `<script_dir>/reduce_<instrument>_post_proc.py` is the
45-
post-processing script (for the accumulated data). To disable this
46-
step rename the python script so it is not found by the daemon.
4755

48-
Example filenames for NOMAD with default script location is
56+
- [livereduce.sh](../scripts/livereduce.sh) is the script that is run when the service is started.
57+
This shell script invokes `livereduce.py` within a conda environment
58+
specified in the configuration file. Otherwise the environment is set to `"mantid-dev"`.
59+
- [livereduce.py](../scripts/livereduce.py) script manages live data reduction using the Mantid framework.
60+
It configures logging, handles signals for graceful termination, reads the configuration JSON,
61+
and manages live data processing with Mantid's StartLiveData and MonitorLiveData algorithms.
62+
The script monitors memory usage and restarts the live data processing if memory limits are exceeded.
63+
It uses `pyinotify` to watch for changes in configuration and processing scripts,
64+
restarting the live data processing as needed. The service relies on instrument-specific processing scripts
65+
for data accumulation and reduction
66+
- `<script_dir>/reduce_<instrument>_proc.py` is the instrument-specific processing script for each chunk (required).
67+
- `<script_dir>/reduce_<instrument>_post_proc.py` is the post-processing script for the accumulated data.
68+
To disable this step rename the python script so it is not found by the daemon.
69+
70+
Example instrument-specific scripts for NOMAD with default script location are
4971
`/SNS/NOM/shared/livereduce/reduce_NOM_live_proc.py` and
5072
`/SNS/NOM/shared/livereduce/reduce_NOM_live_post_proc.py`.
5173

74+
5275
Behavior
5376
--------
5477

@@ -63,6 +86,7 @@ The process will exit and systemd will restart it if the configuration
6386
file is changed. This is done in case the version of mantid wanted is
6487
changed.
6588

89+
6690
Building and packaging
6791
----------------------
6892

@@ -90,18 +114,6 @@ conda env create # looks at environment.yml
90114
pre-commit install
91115
```
92116

93-
Python 3 compatibility
94-
----------------------
95-
96-
`livereduce.py` is python2/3 compatible. Because
97-
the [`livereduce.service`](livereduce.service) file is written to use
98-
system python, whether it is actually using python 2 or 3 will depend
99-
on your system's default python. The other thing to note, is that
100-
`livereduce.py` imports mantid directly in its namespace so you must
101-
run `livereduce.py` using the same python that mantid was built
102-
against.
103-
104-
105117
Acknowledgements and other links
106118
--------------------------------
107119
Information and ideas taken from:

0 commit comments

Comments
 (0)