Frist: init code.

This commit is contained in:
이수준 2023-10-23 10:51:21 +09:00
commit d53e4efc4a
6 changed files with 68 additions and 0 deletions

10
app-setting.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ -z $1 ]; then
echo "Please fill in app's name."
exit
fi
mv sdt-cloud-app.service $1.service
sudo sed -i "s/sdt-cloud-app/$1/g" ./install.sh

9
config1.json Normal file
View File

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

6
config2.json Normal file
View File

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

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/sdt-cloud-app.service
sudo cp /usr/local/sdt/app/$1/sdt-cloud-app.service /etc/systemd/system/$1.service
sudo systemctl start $1
sudo systemctl enable $1

24
main.py Normal file
View File

@ -0,0 +1,24 @@
import paho.mqtt.client as mqtt
import json
import argparse
from datetime import datetime
import time
import yaml
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)
# mqttc = mqtt.Client() # puclisher 이름
# mqttc.username_pw_set("sdt", "251327")
# mqttc.connect("13.209.39.139", 32259)
while True:
print(f"Config value: {jsonData['topic']}", flush=True)
time.sleep(2)

10
sdt-cloud-app.service Normal file
View File

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