[Unit]
Description=Cloud Drive Backend Service
Documentation=https://github.com/your-repo/cloud-drive
After=network.target mysql.service redis.service
Wants=mysql.service redis.service

[Service]
Type=simple
User=cloud-drive
Group=cloud-drive
WorkingDirectory=/opt/cloud-drive
ExecStart=/opt/cloud-drive/cloud-drive-server
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=10
StartLimitInterval=60
StartLimitBurst=3

# 环境变量
Environment=PYTHONPATH=/opt/cloud-drive
Environment=ENVIRONMENT=production

# 安全设置
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/opt/cloud-drive/logs /opt/cloud-drive/uploads

# 资源限制
LimitNOFILE=65536
LimitNPROC=4096

# 日志
StandardOutput=journal
StandardError=journal
SyslogIdentifier=cloud-drive

[Install]
WantedBy=multi-user.target