# Systemd

{% hint style="warning" %}
&#x20;This document assumes `/home/ubuntu` is the server user home directory, make sure to change it to fit the directory of your choice.
{% endhint %}

Prerequisites:

* Install [Git](https://www.atlassian.com/git/tutorials/install-git?linuxc#linux) to clone the zen-oracle repository
* Install [mono-devel](http://www.mono-project.com/download). If you choose to install via a package manager, add Mono's own repository first.
* Install the Headless Node and import a funded account
* Cron **(Optional)**
* Install [MongoDB](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/)

## Oracle Service File&#x20;

#### `Save it in path: /etc/systemd/system/zen-oracle.service`

```bash
[Unit]
Description=Oracle
After=network.target

[Service]
Type=simple
EnvironmentFile=/home/ubuntu/services/scripts/env
WorkingDirectory=/home/ubuntu/services/zen-oracle/src/Oracle/bin/Release
ExecStart=/usr/bin/mono /home/ubuntu/services/zen-oracle/src/Oracle/bin/Release/zen-oracle.exe s
Restart=on-failure

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

## Oracle Service

1. Get the oracle service (from GitLab)

   ```bash
    mkdir /home/ubuntu/services
    cd /home/ubuntu/services
    git clone https://gitlab.com/zenprotocol/zen-oracle.git
   ```
2. Build the oracle service

   ```bash
    cd /home/ubuntu/services/zen-oracle
    ./paket restore
    msbuild src/zen-oracle.sln /p:Configuration=Release
   ```
3. Create `/etc/systemd/system/zen-oracle.service` service file as mentioned above
4. Put all the environment variables assignments in the file `/home/ubuntu/services/scripts/env`
5. Follow node deployment instructions and be sure to have the zen-node service enabled
6. Enable Zen-Oracle

   ```bash
   sudo systemctl enable zen-oracle
   ```
7. Start MongoDB

   ```bash
    sudo systemctl start mongodb
   ```
8. Start Zen-Oracle Server

   ```bash
   sudo systemctl start zen-oracle
   ```

## Execution Scripts

1. Make sure all the environment variables are provided and correct
   * zen\_path : path of the oracle committer
   * zen\_wallet\_password: password of the F# wallet
   * zen\_node\_uri: uri of the node
   * oracle\_api: `uri:port` api port for oracle requests

## Cron job

* In order to commit at a precise time we suggest to use a script in a cron job to take care of the commitment.


---

# 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.zenprotocol.com/apps/oracle/deploy/deployment-on-ubuntu.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.
