Skip to content

Commit 9e489ff

Browse files
authored
Update systemd tutorial (#113)
1 parent c43c284 commit 9e489ff

1 file changed

Lines changed: 35 additions & 74 deletions

File tree

content/tutorials/linux-systemd.md

Lines changed: 35 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Run Pactus with systemd on Linux
2+
title: Run Pactus as a Systemd Service
33
weight: 11
44
---
55

@@ -19,92 +19,53 @@ Before setting up Pactus to run with systemd, ensure you have the following:
1919

2020
## Creating a systemd Service
2121

22-
To create a systemd service for Pactus, follow these steps:
22+
After initializing your Pactus node with `pactus-daemon init`, you can set up
23+
a systemd service to run it in the background.
2324

24-
1. **Initialize the Pactus Node**: Before running the service, initialize the Pactus node with this command:
25+
1. **Create a Service File**: Open a terminal and
26+
create a new service file in the `/etc/systemd/system/` directory with superuser permissions:
2527

26-
```shell
27-
pactus-daemon init
28-
```
28+
```shell
29+
sudo nano /etc/systemd/system/pactus.service
30+
```
2931

30-
2. **Create a Service File**: Open a terminal and
31-
create a new service file in the `/etc/systemd/system/` directory with superuser permissions:
32+
2. **Add the Following Content** to the service file, replacing `<USER_NAME>` with your actual Linux username:
3233

33-
```shell
34-
sudo nano /etc/systemd/system/pactus.service
35-
```
34+
```ini
35+
[Unit]
36+
Description=Pactus Daemon Service
37+
After=network.target
3638

37-
3. **Add the Following Content** to the service file, replacing `<USER_NAME>` with your actual username:
39+
[Service]
40+
Type=simple
41+
User=<USER_NAME>
42+
ExecStart=/home/<USER_NAME>/pactus-cli/pactus-daemon start -w /home/<USER_NAME>/pactus
43+
Restart=on-failure
44+
RestartSec=10
3845

39-
```ini
40-
[Unit]
41-
Description=Pactus Daemon Service
42-
After=network.target
46+
[Install]
47+
WantedBy=multi-user.target
48+
```
4349

44-
[Service]
45-
Type=simple
46-
User=<USER_NAME>
47-
ExecStart=/home/<USER_NAME>/pactus-cli/pactus-daemon start -w /home/<USER_NAME>/pactus
48-
Restart=on-failure
49-
RestartSec=10
50-
51-
[Install]
52-
WantedBy=multi-user.target
53-
```
54-
55-
4. **Reload Systemd Configuration**: After creating or modifying the service file,
50+
3. **Reload Systemd Configuration**: After creating or modifying the service file,
5651
reload the systemd to recognize the new service:
5752

58-
```shell
59-
sudo systemctl daemon-reload
60-
```
61-
62-
5. **Start and Enable the Service**: Start the service immediately and enable it to start on boot:
63-
64-
```shell
65-
sudo systemctl start pactus
66-
sudo systemctl enable pactus
67-
```
68-
69-
6. **Check Service Status**: Check the status of your service to ensure it is running correctly:
70-
71-
```shell
72-
sudo systemctl status pactus
73-
```
74-
75-
## Managing the Service
76-
77-
Use these commands to manage the Pactus service with systemd:
78-
79-
- **Start the Service**:
80-
81-
```shell
82-
sudo systemctl start pactus
83-
```
84-
85-
- **Stop the Service**:
86-
87-
```shell
88-
sudo systemctl stop pactus
89-
```
90-
91-
- **Restart the Service**:
92-
93-
```shell
94-
sudo systemctl restart pactus
95-
```
53+
```shell
54+
sudo systemctl daemon-reload
55+
```
9656

97-
- **Enable the Service to Start on Boot**:
57+
4. **Start and Enable the Service**: Start the service immediately and enable it to start on boot:
9858

99-
```shell
100-
sudo systemctl enable pactus
101-
```
59+
```shell
60+
sudo systemctl start pactus
61+
sudo systemctl enable pactus
62+
```
10263

103-
- **Disable the Service from Starting on Boot**:
64+
5. **Check Service Status**: Check the status of your service to ensure it is running correctly:
10465

105-
```shell
106-
sudo systemctl disable pactus
107-
```
66+
```shell
67+
sudo systemctl status pactus
68+
```
10869

10970
## Checking Logs
11071

0 commit comments

Comments
 (0)