使用supervisor進程管理工具
## supervisor
[supervisor安裝](https://codelife.xin/article/15.html#%E5%AE%89%E8%A3%85supervisor)
創建項目配置文件 `vim project.conf`
```
[program:project-name]
command = nohup 項目絕對路徑/main &
directory = 項目絕對路徑
user =root
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true
stderr_logfile=/data/logs/error.log #錯誤日志文件必須存在
```
## Nginx配置
```
server{
listen 80;
server_name xxx.com;
rewrite ^ https://$http_host$request_uri? permanent;
}
server
{
listen 443 ssl;
server_name xxx.com ;
ssl_certificate /usr/local/nginx/ssl/xxx.pem;
ssl_certificate_key /usr/local/nginx/ssl/xxx.key;
location / {
try_files /_not_exists_ @backend;
}
location @backend {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8080; #轉發到項目運行的端口
}
access_log off;
error_log /data/logs/error-api.log;
}
```