> For the complete documentation index, see [llms.txt](https://qubetics.gitbook.io/qubetics-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qubetics.gitbook.io/qubetics-docs/solver-node-setup-guide/run-mpc-node-in-the-background.md).

# Run MPC Node in the Background

This guide explains how to run the MPC node in the background using `systemd`.

With this setup, the MPC node will:

```
Run in the backgroundRestart automatically if it stops or crashesStart automatically after server rebootStore logs in a log file
```

***

### File Locations Used

This setup uses two main files:

```
Startup script:       /data/mpcn.shSystemd service file: /etc/systemd/system/mpc-node.service
```

Other important paths:

```
MPC node binary:      /data/mpc-nodeLog file:             /data/logs/mpc-node.log
```

The systemd service file must be stored inside:

```
/etc/systemd/system/
```

This allows `systemctl` to detect and manage the MPC node service.

***

## Step 1: Make sure the MPC node binary exists

The MPC node binary should be available at:

```
/data/mpc-node
```

Give it executable permission:

```
sudo chmod +x /data/mpc-node
```

***

## Step 2: Create the startup script

Create the startup script inside `/data`:

```
sudo nano /data/mpcn.sh
```

Add the following content:

```
#!/bin/bash/data/mpc-node
```

Save and exit the file.

Give the script executable permission:

```
sudo chmod +x /data/mpcn.sh
```

***

### Example startup script

File location:

```
/data/mpcn.sh
```

Script content:

```
#!/bin/bash/data/mpc-node
```

This script starts the actual MPC node binary.

***

## Step 3: Create the log directory

Create a folder where the MPC node logs will be stored:

```
sudo mkdir -p /data/logs
```

Logs will be written to:

```
/data/logs/mpc-node.log
```

***

## Step 4: Create the systemd service file

Create the systemd service file at the correct location:

```
sudo nano /etc/systemd/system/mpc-node.service
```

Add the following content:

```
[Unit]Description=MPC NodeAfter=network.target[Service]WorkingDirectory=/dataExecStart=/data/mpcn.shRestart=alwaysRestartSec=5User=rootStandardOutput=append:/data/logs/mpc-node.logStandardError=append:/data/logs/mpc-node.log[Install]WantedBy=multi-user.target
```

Save and exit the file.

***

### Example systemd service file

File location:

```
/etc/systemd/system/mpc-node.service
```

Service file content:

```
[Unit]Description=MPC NodeAfter=network.target[Service]WorkingDirectory=/dataExecStart=/data/mpcn.shRestart=alwaysRestartSec=5User=rootStandardOutput=append:/data/logs/mpc-node.logStandardError=append:/data/logs/mpc-node.log[Install]WantedBy=multi-user.target
```

This service file tells systemd:

```
Run the node from /dataStart it using /data/mpcn.shRestart it automatically if it stopsSave logs to /data/logs/mpc-node.log
```

***

## Step 5: Reload systemd

After creating or updating the service file, reload systemd:

```
sudo systemctl daemon-reload
```

This allows systemd to detect the new MPC node service.

***

## Step 6: Start the MPC node service

Start the MPC node in the background:

```
sudo systemctl start mpc-node
```

***

## Step 7: Enable auto-start on server reboot

Enable the service so the MPC node starts automatically whenever the server restarts:

```
sudo systemctl enable mpc-node
```

***

## Step 8: Check the service status

Check whether the MPC node is running:

```
sudo systemctl status mpc-node
```

***

## Step 9: View live logs

To view live logs from the MPC node:

```
tail -f /data/logs/mpc-node.log
```

***

## Step 10: Restart the MPC node

To restart the node manually:

```
sudo systemctl restart mpc-node
```

***

## Step 11: Stop the MPC node

To stop the node:

```
sudo systemctl stop mpc-node
```

***

## Final Flow

```
systemd  ↓/etc/systemd/system/mpc-node.service  ↓/data/mpcn.sh  ↓/data/mpc-node
```

***

## Summary

Once this setup is complete, users can manage the MPC node from anywhere using `systemctl`:

```
sudo systemctl start mpc-nodesudo systemctl stop mpc-nodesudo systemctl restart mpc-nodesudo systemctl status mpc-node
```

The node will continue running in the background, automatically restart if it crashes, and store all logs at:

```
/data/logs/mpc-node.log
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://qubetics.gitbook.io/qubetics-docs/solver-node-setup-guide/run-mpc-node-in-the-background.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
