# Service Setup Guide This guide describes how to set up the OpenVPN Monitor components as system services. ## Components 1. **ovpmon-api**: The main Flask API (`APP/openvpn_api_v3.py`). 2. **ovpmon-gatherer**: The background data gatherer (`APP/openvpn_gatherer_v3.py`). 3. **ovpmon-profiler**: The new FastAPI profiler module (`NEW_MODULES/main.py`). ## Common Prerequisites - **Install Directory**: `/opt/ovpmon` (Recommended) - **Virtual Environment**: `/opt/ovpmon/venv` --- ## 1. Alpine Linux (OpenRC) ### Installation 1. **Copy Service Scripts**: Copy the scripts from `Deployment/APP/openrc/` to `/etc/init.d/`. ```sh cp DOCS/General/openrc/ovpmon-api /etc/init.d/ cp DOCS/General/openrc/ovpmon-gatherer /etc/init.d/ cp DOCS/General/openrc/ovpmon-profiler /etc/init.d/ ``` 2. **Set Permissions**: ```sh chmod +x /etc/init.d/ovpmon-* ``` 3. **Enable Services**: ```sh rc-update add ovpmon-api default rc-update add ovpmon-gatherer default rc-update add ovpmon-profiler default ``` 4. **Start Services**: ```sh rc-service ovpmon-api start rc-service ovpmon-gatherer start rc-service ovpmon-profiler start ``` ### Configuration To override defaults (e.g., if you installed to a different directory), create files in `/etc/conf.d/`: **File:** `/etc/conf.d/ovpmon-api` (example) ```sh directory="/var/www/my-monitoring" command_args="/var/www/my-monitoring/APP_CORE/openvpn_api_v3.py" ``` --- ## 2. Debian / Ubuntu (Systemd) ### Installation Steps 1. **Copy Service Files**: Copy the provided service files from `DOCS/General/systemd/` to `/etc/systemd/system/`. ```bash cp DOCS/General/systemd/ovpmon-api.service /etc/systemd/system/ cp DOCS/General/systemd/ovpmon-gatherer.service /etc/systemd/system/ cp DOCS/General/systemd/ovpmon-profiler.service /etc/systemd/system/ ``` 2. **Reload Daemon**: ```bash systemctl daemon-reload ``` 3. **Enable Services** (Start on boot): ```bash systemctl enable ovpmon-api ovpmon-gatherer ovpmon-profiler ``` 4. **Start Services**: ```bash systemctl start ovpmon-api ovpmon-gatherer ovpmon-profiler ``` 5. **Check Status**: ```bash systemctl status ovpmon-api ```