# Configuring for Boot

The Data Gateway can be configured to boot automatically with its host at startup. The exact steps depend on the system you are using.

{% hint style="warning" %}
If you update the Data Gateway, make sure to update the executable reference in your startup configuration.
{% endhint %}

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

For a Linux system, you have several options depending on your specific distribution and preferences.

### 1. Using `cron` with `@reboot` <a href="#id-1-using-cron-with-reboot" id="id-1-using-cron-with-reboot"></a>

Cron is a time-based job scheduler in Unix-like operating systems. You can schedule the gateway to run at reboot by adding an entry to the crontab.

1. Open the crontab configuration:

```bash
crontab -e
```

2. Add a line in the following format:

```bash
@reboot /path/to/your/gateway
```

Replace `/path/to/your/gateway` with the path to the Data Gateway.

### 2. Using Systemd Services (Common in Modern Linux Distributions)[​](https://docs.lumi-ai.com/product-features/data-gateway/broken-reference) <a href="#id-2-using-systemd-services-common-in-modern-linux-distributions" id="id-2-using-systemd-services-common-in-modern-linux-distributions"></a>

If your system uses `systemd`, you can create a custom service to run the gateway.

1. Create a new service file in `/etc/systemd/system`, e.g., `lumi_ai_data_gateway.service`:

   ```
   sudo nano /etc/systemd/system/lumi_ai_data_gateway.service
   ```
2. Add the following content to the service file:

   ```bash
   [Unit]
   Description=Lumi AI Data Gateway

   [Service]
   ExecStart=/path/to/your/gateway

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

   Replace `/path/to/your/gateway` with the path to your executable.
3. Enable the service to start on boot:

   ```bash
   sudo systemctl enable lumi_ai_data_gateway.service
   ```
4. Start the service immediately if you want to:

   ```bash
   sudo systemctl start lumi_ai_data_gateway.service
   ```

### 3. Using `rc.local` (For Older Systems or Specific Use Cases) <a href="#id-3-using-rclocal-for-older-systems-or-specific-use-cases" id="id-3-using-rclocal-for-older-systems-or-specific-use-cases"></a>

On older systems, or systems without `systemd`, you can use `rc.local`.

1. Edit the `rc.local` file:

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

2. Add the command to run the gateway before the `exit 0` line:

```bash
/path/to/your/gateway
exit 0
```

Ensure that the gateway has executable permissions:

```bash
chmod +x /path/to/your/gateway
```

### 4. Using Desktop Environment Autostart (For GUI) <a href="#id-4-using-desktop-environment-autostart-for-gui" id="id-4-using-desktop-environment-autostart-for-gui"></a>

If you are using a Linux desktop environment, you can often add tasks to run at startup through the desktop environment's settings.

* For GNOME, use `gnome-session-properties`.
* For KDE, use the Autostart module in System Settings.
* For other desktop environments, check their specific documentation.

#### Important Notes <a href="#important-notes" id="important-notes"></a>

* Ensure that the gateway has execution permissions (`chmod +x <data-gateway-filename>`).
* The choice of method depends on your specific Linux distribution and whether you are using a system with or without a GUI.
* Always test your configuration to ensure that it behaves as expected on system startup.

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

For Windows, you can use the methods as described below:

### 1. Using Startup Folder <a href="#id-1-using-startup-folder" id="id-1-using-startup-folder"></a>

This is the simplest method and works well for a single account on the host.

#### **For a Specific User:**

1. Press `Win + R` to open the Run dialog.
2. Type `shell:startup` and press Enter. This opens the Startup folder for your user account.
3. Place a shortcut to the gateway in this folder.

#### **For All Users:**

1. Open the Run dialog (`Win + R`).
2. Type `shell:common startup` and press Enter. This opens the common Startup folder.
3. Place a shortcut to the gateway in this folder. (Note: You need administrative privileges for this action.)

### 2. Using Task Scheduler <a href="#id-2-using-task-scheduler" id="id-2-using-task-scheduler"></a>

Task Scheduler allows more control, like running a program at system startup with a delay or specific conditions.&#x20;

To configure Data Gateway to start on system startup, follow these instructions:

1. Open Task Scheduler (you can search for it in the Start menu).
2. Create a New Task
   * Click on Create Task.
3. Configure the General Settings
   * Nam&#x65;**:** Enter the task name (e.g., `Lumi AI Gateway`).
   * User/Group: Click on Change User or Group, type `SYSTEM` in the text field, and confirm.
4. Set Up the Trigger
   * Navigate to the Triggers tab.
   * Click the New\... button.
   * In the Begin the task dropdown, select At startup.
   * Click OK.
5. Define the Action
   * Switch to the Actions tab.
   * Click the New\... button.
   * Click Browse..., then select the Lumi Gateway executable (e.g., `C:\lumi-ai\lumi-ai-data-gateway-windows-vX.X.XX`).
   * In the Start in (optional) field, enter the path to the parent folder where executable is located (e.g., `C:\lumi-ai`).
   * Click OK.
6. Adjust Conditions
   * Go to the Conditions tab.
   * Uncheck Start the task only if the computer is on AC power.
7. Modify Settings
   * Open the Settings tab.
   * Uncheck Stop the task if it runs longer than:.
8. Finalize the Task
   * Click OK to save the new task.
9. Restart Your Computer
   * Reboot to apply the changes.

### 3. Using Group Policy Editor <a href="#id-3-using-group-policy-editor" id="id-3-using-group-policy-editor"></a>

For professional and enterprise versions of Windows, you can use Group Policy Editor.

1. Make a `bat` file with `start "" "C:\path\to\your\gateway.exe"`
2. Open Group Policy Editor (type `gpedit.msc` in the Run dialog).
3. Navigate to `User Configuration -> Windows Settings -> Scripts (Logon/Logoff)` or `Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdown)`.
4. Add the gateway here.

#### Important Notes <a href="#important-notes-1" id="important-notes-1"></a>

* Always test your configuration to ensure that it behaves as expected on system startup.
