Skip to content

Commit 8327f2b

Browse files
Move scripts from gitops repository
1 parent 2dd08e9 commit 8327f2b

12 files changed

+249
-1
lines changed

.cursorignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/.env*
2+

stress-l3/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.env
1+
**/.env*
22
*.log
33

44
__pycache__

stress-l3/master/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Locust Master Service Setup for Arkiv
2+
3+
This guide explains how to set up the Locust master service for Arkiv load testing using systemd.
4+
5+
## Prerequisites
6+
7+
1. Ensure you have Poetry installed:
8+
9+
```bash
10+
curl -sSL https://install.python-poetry.org | python3 -
11+
```
12+
13+
2. Clone this repository to a location accessible by the systemd service user (e.g., `/root/locus-master/loadtest-yagna`):
14+
15+
```bash
16+
git clone <repository-url> /root/locus-master/loadtest-yagna
17+
cd /root/locus-master/loadtest-yagna
18+
```
19+
20+
3. Install dependencies using Poetry:
21+
22+
```bash
23+
poetry install
24+
```
25+
26+
## Arkiv Service Setup
27+
28+
1. Copy the systemd service file to the systemd directory:
29+
30+
```bash
31+
sudo cp stress-l3/systemd/locust-arkiv.service /etc/systemd/system/
32+
```
33+
34+
2. **Important**: Update the `WorkingDirectory` path in `/etc/systemd/system/locust-arkiv.service` to match the actual location where you cloned the repository. The default path in the example file is `/root/locus-master/loadtest-yagna`.
35+
36+
3. Activate and start the service:
37+
38+
```bash
39+
sudo systemctl daemon-reload
40+
sudo systemctl enable locust-arkiv.service
41+
sudo systemctl start locust-arkiv.service
42+
sudo systemctl status locust-arkiv.service
43+
```
44+
45+
To view logs: `sudo journalctl -u locust-arkiv.service -f`
46+
47+
## Service Configuration
48+
49+
The service file (`stress-l3/systemd/locust-arkiv.service`) is configured to:
50+
51+
- Run Locust in master mode
52+
- Bind the web interface to `0.0.0.0` (accessible from all network interfaces)
53+
- Automatically restart on failure with a 5-second delay
54+
- Start automatically on system boot
55+
56+
**Note**: Scripts for running distributed nodes are placed in https://github.com/golemfactory/gitops
57+
58+
## Stopping the Service
59+
60+
To stop the service:
61+
62+
```bash
63+
sudo systemctl stop locust-arkiv.service
64+
```
65+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=Locust Arkiv Load Testing Master
3+
After=network.target
4+
5+
[Service]
6+
WorkingDirectory=WORKING_DIRECTORY_PLACEHOLDER
7+
EnvironmentFile=ENV_FILE_PLACEHOLDER
8+
ExecStart=/usr/bin/poetry run locust -f LOCUST_FILE_PLACEHOLDER --master --web-host 0.0.0.0
9+
Restart=always
10+
RestartSec=5
11+
User=root
12+
13+
[Install]
14+
WantedBy=multi-user.target
15+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Setup Locust master service
3+
4+
# Get the directory where this script is located
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
7+
# Source master environment configuration
8+
source "$SCRIPT_DIR/.env-master.sh"
9+
10+
# Allow command line arguments to override env variables
11+
# Default working directory is the stress-l3 root directory
12+
WORKING_DIRECTORY="${1:-$(cd "$SCRIPT_DIR/.." && pwd)}"
13+
14+
echo "Setting up Locust master with working directory: $WORKING_DIRECTORY"
15+
16+
# Create locust service file with parameterized working directory
17+
echo "Creating locust master systemd service..."
18+
cp "$SCRIPT_DIR/locust-arkiv.service.template" /tmp/locust-arkiv.service
19+
20+
# Replace placeholders in the service file
21+
ENV_FILE="$SCRIPT_DIR/../.env-public"
22+
LOCUST_FILE="$SCRIPT_DIR/../$LOCUST_FILE"
23+
24+
sed -i "s|ENV_FILE_PLACEHOLDER|$ENV_FILE|g" /tmp/locust-arkiv.service
25+
sed -i "s|WORKING_DIRECTORY_PLACEHOLDER|$WORKING_DIRECTORY|g" /tmp/locust-arkiv.service
26+
sed -i "s|LOCUST_FILE_PLACEHOLDER|$LOCUST_FILE|g" /tmp/locust-arkiv.service
27+
28+
sudo mv /tmp/locust-arkiv.service /etc/systemd/system/locust-arkiv.service
29+
echo "Locust master systemd service created."
30+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Start Locust master service
3+
4+
echo "Starting locust master service..."
5+
sudo systemctl daemon-reload
6+
sudo systemctl enable locust-arkiv.service
7+
sudo systemctl start locust-arkiv.service
8+
echo "Locust master service started."
9+
10+
echo "Checking status of locust master service..."
11+
sudo systemctl status locust-arkiv.service
12+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Install Promtail binary
3+
4+
echo "Installing Promtail..."
5+
wget https://github.com/grafana/loki/releases/download/v2.9.1/promtail-linux-amd64.zip
6+
unzip promtail-linux-amd64.zip
7+
sudo mv promtail-linux-amd64 /usr/local/bin/promtail
8+
echo "Promtail installed."
9+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=Locust Worker Service
3+
After=network.target
4+
5+
[Service]
6+
User=ubuntu
7+
Group=ubuntu
8+
WorkingDirectory=WORKING_DIRECTORY_PLACEHOLDER
9+
EnvironmentFile=ENV_FILE_PLACEHOLDER
10+
ExecStartPre=/bin/sleep 30
11+
ExecStart=/usr/bin/poetry run locust -f LOCUST_FILE_PLACEHOLDER --worker --master-host MASTER_HOST_PLACEHOLDER --master-port MASTER_PORT_PLACEHOLDER
12+
Restart=on-failure
13+
14+
[Install]
15+
WantedBy=multi-user.target
16+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server:
2+
http_listen_port: 9080
3+
grpc_listen_port: 0
4+
5+
positions:
6+
filename: /tmp/positions.yaml
7+
8+
clients:
9+
- url: http://grafana.dev.golem.network:3100/loki/api/v1/push
10+
11+
scrape_configs:
12+
- job_name: journal
13+
journal:
14+
max_age: 12h
15+
path: /var/log/journal
16+
labels:
17+
job: systemd-journal
18+
hostname: "$(hostname)"
19+
relabel_configs:
20+
- source_labels: ['__journal__systemd_unit']
21+
target_label: 'unit'
22+

stress-l3/worker/promtail.service

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Promtail service
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
User=root
8+
ExecStart=/usr/local/bin/promtail -config.file /etc/promtail/config.yml
9+
Restart=on-failure
10+
11+
[Install]
12+
WantedBy=multi-user.target
13+

0 commit comments

Comments
 (0)