# Configuring the Data Gateway for Boot

The Data Gateway can be configured to start automatically when its host starts up. The exact steps depend on the operating system.

{% hint style="warning" %}
When you update the Data Gateway executable, update any file path references in your startup configuration to point to the new version.
{% endhint %}

## Linux <a href="#linux" id="linux"></a>

### Using `systemd` (Recommended)

`systemd` is the standard service manager on modern Linux distributions (Ubuntu, Debian, RHEL, Fedora, etc.) and is the recommended approach for production deployments. It handles automatic restart on failure and integrates with the system journal.

Create a new service file:

```bash
sudo nano /etc/systemd/system/lumi-data-gateway.service 
```

Add the following content, substituting the actual executable filename and a dedicated service user:

```systemd
[Unit]
Description=Lumi AI Data Gateway
After=network-online.target
Wants=network-online.target

[Service]
User=lumi
WorkingDirectory=/opt/lumi-gateway
ExecStart=/opt/lumi-gateway/lumi-agent-linux-vX.X.XX
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
```

* `ExecStart` — full absolute path to the executable. The gateway locates `config.yaml` and writes its `logs` folder relative to the executable itself, so the directory containing the binary is what matters, not `WorkingDirectory`.
* `User` — a dedicated non-root user is recommended. Create one with `useradd -r -s /bin/false lumi` if it doesn't exist, and ensure it has read/write access to the gateway directory.
* `Restart=on-failure / RestartSec=10` — automatically restarts the gateway if it exits unexpectedly, with a 10-second delay.

Reload `systemd` and enable the service to start at boot:

```bash
sudo systemctl daemon-reload 
sudo systemctl enable lumi-data-gateway.service 
```

Start the service immediately:

```bash
sudo systemctl start lumi-data-gateway.service 
```

Confirm it is running:

```bash
sudo systemctl status lumi-data-gateway.service
```

### Using `cron` with `@reboot`

A simpler option for systems without `systemd` or for quick setups.

Open the crontab for the user that will run the gateway:

```bash
crontab -e 
```

Add a line using the full absolute path to the executable:

```bash
@reboot /opt/lumi-gateway/lumi-agent-linux-vX.X.XX
```

Use the full absolute path — the gateway resolves `config.yaml` and `logs` relative to the executable itself, so there is no need to `cd` first.

### Using `rc.local` (Older Systems)

Edit `rc.local`:

```bash
sudo nano /etc/rc.local 
```

Add the following before the `exit 0` line:

```bash
/opt/lumi-gateway/lumi-agent-linux-vX.X.XX &
```

Ensure `rc.local` is executable:

```bash
sudo chmod +x /etc/rc.local
```

### Desktop Environment Autostart (GUI)

If running on a Linux desktop, use the built-in autostart mechanism for your environment:

* **GNOME**: `gnome-session-properties`
* **KDE**: Autostart module in System Settings
* Other environments: refer to their documentation

Note: desktop autostart only runs when the user is logged in. For unattended or server deployments, `systemd` is the appropriate choice.

## Windows <a href="#windows" id="windows"></a>

### Using Windows Service (Recommended for Production)

The Windows gateway executable includes built-in Windows Service support — the recommended approach for production deployments. The service runs under the SYSTEM account, starts at boot without requiring a user login, and restarts automatically on failure.

**Install the service:**

Open a Command Prompt or PowerShell **as Administrator** in the directory containing the gateway executable, then run:

```bash
.\lumi-agent-windows-vX.X.XX.exe --install-service
```

This installs and starts the service with the default name `LumiAIDataGateway`. To use a custom name (e.g., for multiple instances):

```bash
.\lumi-agent-windows-vX.X.XX.exe --install-service --service-name MyGateway
```

After installation, the service will start automatically on the next reboot and on any subsequent failure. You can also start it immediately from Services (`services.msc`) or via:

```bash
net start LumiAIDataGateway
```

**Uninstall the service:**

```bash
.\lumi-agent-windows-vX.X.XX.exe --remove-service LumiAIDataGateway
```

{% hint style="info" %}
The gateway reads `config.yaml` from the same directory as the executable when running as a service. Ensure the config file is in place before installing, or supply the token via the `LUMI_AI_DATA_GATEWAY_TOKEN` environment variable set at the system level.
{% endhint %}

### Using Task Scheduler

An alternative to the Windows Service, suitable if you prefer not to use the built-in service mode.

1. Open **Task Scheduler** (search for it in the Start menu) and click **Create Task**.
2. **General tab**: Enter a name (e.g., `Lumi AI Data Gateway`). Click **Change User or Group**, type `SYSTEM`, and confirm.
3. **Triggers tab**: Click **New**..., set **Begin the task** to `At startup,` click **OK**.
4. **Actions tab**: Click **New**..., click **Browse**... and select the gateway executable. In the **Start in (optional)** field, enter the directory containing the executable (e.g., `C:\lumi-gateway`). Click **OK**.
5. **Conditions tab**: Uncheck **Start the task only if the computer is on AC power**.
6. **Settings tab**: Uncheck **Stop the task if it runs longer than**.
7. Click **OK** to save, then reboot to verify the task runs correctly.

### Using Group Policy (Domain-Joined Machines)

For domain-joined machines managed via Group Policy:

1. Create a `.bat` file:

<pre class="language-bat"><code class="lang-bat"><strong>start "" "C:\lumi-gateway\lumi-agent-windows-vX.X.XX.exe"
</strong></code></pre>

2. Open Group Policy Editor (`gpedit.msc`).
3. Navigate to `Computer Configuration → Windows Settings → Scripts (Startup/Shutdown)`.
4. Add the `.bat` file as a Startup script.

***

**After any startup configuration**: reboot the host and confirm the gateway appears as **Active** in the Lumi AI Admin Settings panel.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lumi-ai.com/product-features/data-gateway/configuring-the-data-gateway-for-boot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
