-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstartup-worker.yaml
More file actions
50 lines (45 loc) · 1.53 KB
/
startup-worker.yaml
File metadata and controls
50 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#cloud-config
write_files:
- path: /var/lib/cloud/instance/scripts/runcmd-script.sh
permissions: '0755'
content: |
#!/bin/bash
CPUS=$(nproc --all)
for (( c=1; c<=$CPUS; c++ ))
do
cat <<EOF > /lib/systemd/system/locust-worker-$c.service
[Unit]
Description=Locust Service
Wants=network-online.target
Requires=network-online.target
After=network-online.target
[Service]
User=locust
Group=locust
Restart=always
ExecStart=/usr/local/bin/locust -f tasks.py --worker --master-host=${LOCUST_MASTER_IP} ${LOCUST_TAGS}
WorkingDirectory=/home/locust
KillSignal=SIGKILL
SyslogIdentifier=locust-worker-$c
LimitNOFILE=1000000
LimitMEMLOCK=infinity
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable locust-worker-$c
systemctl restart locust-worker-$c
done
runcmd:
- set -x
- apt update
- apt upgrade -y
- groupadd -f locust
- useradd -m locust -g locust || echo "user already exists"
- apt install -y htop emacs-nox wget iftop iotop python3.11-dev python3-pip python3.11-venv
- pip install locust
- echo '* - nofile 1000000' >> /etc/security/limits.conf
- echo '* - nproc 1000000' >> /etc/security/limits.conf
- echo ${LOCUST_FILE} | base64 -d | tee /home/locust/tasks.py
- chown -R locust:locust /home/locust
- /var/lib/cloud/instance/scripts/runcmd-script.sh