关于服务器后台持续性的问题,之前使用的是nohup这个。 但是更好的做法是使用system的这种。比如:
[Unit]
Description=4DVCam ATS Service
After=network.target
[Service]
Type=simple
ExecStart=/home/clarke/miniconda3/envs/4DV/bin/python /home/clarke/4dcam-ats/main.py
# Ensure that the environment variables are set properly
Environment="4DVCAMATS_ENV=production"
Environment="4DVCAMATS_PORT=5000"
Environment="4DVCAMATS_CAM_CONTROL_PORT=8088"
# Log to the file, append output and error
StandardOutput=append:/home/clarke/4dvcam_ats.log
StandardError=append:/home/clarke/4dvcam_ats.log
# Restart service in case of failure
Restart=always
RestartSec=3
# Run as the correct user and group
User=clarke
Group=clarke
[Install]
WantedBy=default.target