建立 systemd 服務檔案 /etc/systemd/system/stock_web.service
:
[Unit]
Description=Taiwan Stock Web Application
After=network.target
[Service]
Type=simple
User=your_username
WorkingDirectory=/path/to/taiwan_stock_web
Environment=PATH=/path/to/taiwan_stock_web/venv/bin
ExecStart=/path/to/taiwan_stock_web/venv/bin/python app.py
Restart=always
[Install]
WantedBy=multi-user.target
啟用服務:
sudo systemctl daemon-reload
sudo systemctl enable stock_web.service
sudo systemctl start stock_web.service
安全性: 此範例為演示用途,生產環境需要增加安全措施
錯誤處理: 需要增加更完善的錯誤處理和重試機制
沒有留言:
張貼留言