Frist: init code.

This commit is contained in:
이수준 2023-10-20 10:21:40 +09:00
commit 9035834948
5 changed files with 74 additions and 0 deletions

6
HWconfig.json Normal file
View File

@ -0,0 +1,6 @@
{
"hw": "intel",
"cpu": 12,
"memory": 32,
"gpu": "2080TI"
}

10
config.json Normal file
View File

@ -0,0 +1,10 @@
{
"topic": "performance",
"id": "sdt",
"cpu": 2,
"password": "11223344",
"host": {
"address": "192.168.100.200",
"hostname": "sdt"
}
}

9
install.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
sudo sed -i "s/appName/$1/g" /usr/local/sdt/app/$1/load-test.service
sudo cp /usr/local/sdt/app/$1/load-test.service /etc/systemd/system/$1.service
sudo systemctl start $1
sudo systemctl enable $1

10
load-test.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=awx-perfermance
[Service]
ExecStart=/usr/bin/python3 /usr/local/sdt/app/appName/main.py -config appName
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

39
main.py Normal file
View File

@ -0,0 +1,39 @@
import argparse
from multiprocessing import Pool
from multiprocessing import cpu_count
import signal
parser = argparse.ArgumentParser()
parser.add_argument('-config',help='')
args = parser.parse_args()
with open(f'/usr/local/sdt/app/{args.config}/config.json', encoding='UTF-8') as f:
jsonData = json.load(f)
stop_loop = 0
def exit_chld(x, y):
global stop_loop
stop_loop = 1
def f(x):
global stop_loop
while not stop_loop:
x*x
signal.signal(signal.SIGINT, exit_chld)
if __name__ == '__main__':
processes = jsonData["cpu"]
print('-' * 20)
print('Running load on CPU(s)')
print('Utilizing %d cores' % processes)
print('-' * 20)
pool = Pool(processes)
pool.map(f, range(processes))