Metadata-Version: 2.4
Name: remote-svc-ctrl
Version: 0.1.1
Summary: Add your description here
Author-email: Brookhaven National Laboratory <jwlodek@bnl.gov>
License: BSD 3-Clause License
        
        Copyright (c) 2026, Brookhaven National Laboratory.
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the vector package developers nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: softioc>=4.7.0
Dynamic: license-file

# remote-svc-ctrl [![CI](https://github.com/NSLS2/remote-svc-ctrl/actions/workflows/ci.yml/badge.svg)](https://github.com/NSLS2/remote-svc-ctrl/actions/workflows/ci.yml)

An EPICS IOC that monitors and controls systemd services, exposing their status as Process Variables (PVs). Supports both local and remote (via SSH) service management.

This can be particularly useful for managing acquisition/control services on vendor provided systems, such as the Dectris `camserver` service for Pilatus3 detectors, or the `xspd` remote control service from X-Spectrum.

## Features

- Poll `systemctl status` parse its output, and publish relevant information as PVs
- Start, stop, and restart services via CA/PVA
- Monitor over SSH for services running on remote hosts
- Phoebus operator screen included

## Usage

```bash
# Monitor a local service
remote-svc-ctrl "XF:28ID1-CT{SVC-MyApp:1}" my-app.service

# Monitor a service on a remote host via SSH
remote-svc-ctrl "XF:28ID1-CT{SVC-MyApp:1}" my-app.service --host user@server
```

## Operator Screen

A Phoebus `.bob` screen is provided in [`op/service_ctrl.bob`](op/service_ctrl.bob). Open it with the macro `PREFIX` set to your IOC's PV prefix.

![Operator Screen](docs/assets/screenshot.png)

## Documentation

- [PV Reference](docs/pvs.md) — full list of exposed PVs and their behavior
- [Polkit Configuration](docs/polkit.md) — allow non-root service control without a password
- [SSH Key Setup](docs/ssh-setup.md) — configure passwordless SSH for remote host management

## Development

The project uses [uv](https://docs.astral.sh/uv/) for dependency management and task running. To set up the development environment, run:

```bash
uv sync                             # Install dependencies
uv run pytest                       # Unit tests
uv run pre-commit run --all-files   # Linting and formatting
```

## Requirements

- Python >= 3.11
- [pythonSoftIOC](https://github.com/dls-controls/pythonSoftIOC) >= 4.7.0
- `systemctl` available on the target host
- For non-root service control: appropriate polkit rules configured on the target host
- SSH key-based auth configured for remote hosts
