diff --git a/README.md b/README.md index 3d4325c..b1696a9 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,16 @@ GraphQL 基本规则 // 假设服务器上的数据 const database = { users: [ - { id: 1, user_name:'xx1', avatar:'xx1.png', create_time:'2022-01-02 12:12:12' } - { id: 2, user_name:'xx2', avatar:'xx2.png', create_time:'2022-01-02 12:12:12' } - { id: 3, user_name:'xx3', avatar:'xx3.png', create_time:'2022-01-02 12:12:12' } - { id: 4, user_name:'xx4', avatar:'xx4.png', create_time:'2022-01-02 12:12:12' } + { id: 1, user_name:'xx1', avatar:'xx1.png', create_time:'2022-01-02 12:12:12' }, + { id: 2, user_name:'xx2', avatar:'xx2.png', create_time:'2022-01-02 12:12:12' }, + { id: 3, user_name:'xx3', avatar:'xx3.png', create_time:'2022-01-02 12:12:12' }, + { id: 4, user_name:'xx4', avatar:'xx4.png', create_time:'2022-01-02 12:12:12' }, ], images: [ - { id: 1, content:'xx1.png', user_id: 1, article_id: 2, text:['xx1'] } - { id: 2, content:'xx2.png', user_id: 1, article_id: 2, text:['xx2'] } - { id: 3, content:'xx3.png', user_id: 2, article_id: 4, text:['xx3'] } - { id: 4, content:'xx4.png', user_id: 2, article_id: 4, text:['xx4'] } + { id: 1, content:'xx1.png', user_id: 1, article_id: 2, text:['xx1'] }, + { id: 2, content:'xx2.png', user_id: 1, article_id: 2, text:['xx2'] }, + { id: 3, content:'xx3.png', user_id: 2, article_id: 4, text:['xx3'] }, + { id: 4, content:'xx4.png', user_id: 2, article_id: 4, text:['xx4'] }, ] } ``` diff --git a/update.sh b/update.sh index 053f743..ecaf015 100755 --- a/update.sh +++ b/update.sh @@ -13,7 +13,13 @@ scp dist/main $host:~/webp/main rm -rf dist # 重载服务 -ssh $host "pm2 reload webp" +ssh $host "systemctl restart webp" # 删除旧文件 ssh $host "rm ~/webp/main_old" + +# 设为系统服务 +# sudo cp webp.service /etc/systemd/system/webp.service + +# 设置日志轮转 +# sudo cp webp.logrotate /etc/logrotate.d/webp diff --git a/webp.logrotate b/webp.logrotate new file mode 100644 index 0000000..c719b88 --- /dev/null +++ b/webp.logrotate @@ -0,0 +1,12 @@ +# WEBP SERVER +/root/webp/webp.log { + daily + rotate 7 + compress + missingok + notifempty + create 0640 root adm + postrotate + systemctl reload webp.service > /dev/null + endscript +} diff --git a/webp.service b/webp.service new file mode 100644 index 0000000..e6395ac --- /dev/null +++ b/webp.service @@ -0,0 +1,17 @@ +[Unit] +Description=WEBP接口服务 + +[Service] +ExecStart=/root/webp/main +StandardOutput=append:/root/webp/webp.log +StandardError=inherit +Restart=always +User=root +Group=root +Environment=PATH=/usr/bin:/usr/local/bin +Environment=NODE_ENV=production +WorkingDirectory=/root/webp/ +MemoryMax=4G + +[Install] +WantedBy=multi-user.target