diff --git a/aio-3d-huey.service b/aio-3d-huey.service new file mode 100644 index 0000000..79b1444 --- /dev/null +++ b/aio-3d-huey.service @@ -0,0 +1,15 @@ +[Unit] +Description=AIO 3D Printer Slice and Manage Platform Huey Tasks +After=network.target + +[Service] +User=1000 + +WorkingDirectory=/home/lhye200/AIO_3D_Print_Exp/ +ExecStart=/home/lhye200/AIO_3D_Print_Exp/run_huey.sh + +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/aio-3d-main.service b/aio-3d-main.service new file mode 100644 index 0000000..a2f0dbe --- /dev/null +++ b/aio-3d-main.service @@ -0,0 +1,16 @@ +[Unit] +Description=AIO 3D Printer Slice and Manage Platform +After=aio-3d-huey.service network.target +Wants=aio-3d-huey.service network.target + +[Service] +User=1000 + +WorkingDirectory=/home/lhye200/AIO_3D_Print_Exp/ +ExecStart=/home/lhye200/AIO_3D_Print_Exp/run_main.sh + +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4db28bf --- /dev/null +++ b/install.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +echo "Start installation AIO_3D_Print_Exp" + +echo "Clean existing installation" +# rm -rf /opt/AIO_3D_Print_Exp +systemctl stop aio-3d-main.service +systemctl stop aio-3d-huey.service +# rm -rf /etc/systemd/system/aio-3d-main.service +# rm -rf /etc/systemd/system/aio-3d-huey.service + +echo "Copy installation files" +# mkdir -p /opt/AIO_3D_Print_Exp +# cp -r ./. /opt/AIO_3D_Print_Exp/ + +echo "Set execute permissions" +# chmod +x /opt/AIO_3D_Print_Exp/run_main.sh +# chmod +x /opt/AIO_3D_Print_Exp/run_huey.sh + +echo "Copy service files" +# cp /opt/AIO_3D_Print_Exp/aio-3d-main.service /etc/systemd/system/ +# cp /opt/AIO_3D_Print_Exp/aio-3d-huey.service /etc/systemd/system/ +cp /home/lhye200/AIO_3D_Print_Exp/aio-3d-main.service /etc/systemd/system/ +cp /home/lhye200/AIO_3D_Print_Exp/aio-3d-huey.service /etc/systemd/system/ + +echo "Reload systemd daemon" +systemctl daemon-reload +systemctl enable aio-3d-main.service +systemctl enable aio-3d-huey.service +systemctl start aio-3d-huey.service +systemctl start aio-3d-main.service + +echo "Installation completed successfully" + diff --git a/requirements.txt b/requirements.txt index b4f5c90..4ad1ba5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ Werkzeug>=3.0.0 trimesh>=4.0.0 requests>=2.31.0 httpx>=0.25.0 +gunicorn>=26.0.0 \ No newline at end of file diff --git a/run.py b/run.py index ec3428e..a28da85 100644 --- a/run.py +++ b/run.py @@ -23,4 +23,4 @@ def init_admin(): if __name__ == '__main__': init_admin() - app.run(host='0.0.0.0', port=5001, debug=True) + app.run(host='0.0.0.0', port=5001, debug=False) diff --git a/run_huey.sh b/run_huey.sh index b2607ba..b0a808f 100755 --- a/run_huey.sh +++ b/run_huey.sh @@ -1,3 +1,6 @@ #!/bin/bash -venv/bin/huey_consumer run_huey.huey \ No newline at end of file +source "$(dirname "$0")/venv/bin/activate" + +# huey_consumer "run_huey.huey" > /dev/null 2>&1 +huey_consumer "run_huey.huey" \ No newline at end of file diff --git a/run_main.sh b/run_main.sh index ecca62a..ab6c5c3 100755 --- a/run_main.sh +++ b/run_main.sh @@ -1,3 +1,9 @@ #!/bin/bash -venv/bin/python run.py +source "$(dirname "$0")/venv/bin/activate" + +# python "$(dirname "$0")/run.py" > /dev/null 2>&1 +# python "$(dirname "$0")/run.py" + +python -c "from run import init_admin; init_admin()" # 确保管理员初始化被执行 +gunicorn -w 4 -b 0.0.0.0:5001 "run:app"