弃用 pm2, 使用 systemctl 管理进程
This commit is contained in:
		
							
								
								
									
										16
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								README.md
									
									
									
									
									
								
							@@ -17,16 +17,16 @@ GraphQL 基本规则
 | 
				
			|||||||
// 假设服务器上的数据
 | 
					// 假设服务器上的数据
 | 
				
			||||||
const database = {
 | 
					const database = {
 | 
				
			||||||
    users: [
 | 
					    users: [
 | 
				
			||||||
        { id: 1, user_name:'xx1', avatar:'xx1.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: 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: 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: 4, user_name:'xx4', avatar:'xx4.png', create_time:'2022-01-02 12:12:12' },
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    images: [
 | 
					    images: [
 | 
				
			||||||
        { id: 1, content:'xx1.png', user_id: 1, article_id: 2, text:['xx1'] }
 | 
					        { 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: 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: 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: 4, content:'xx4.png', user_id: 2, article_id: 4, text:['xx4'] },
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,13 @@ scp dist/main $host:~/webp/main
 | 
				
			|||||||
rm -rf dist
 | 
					rm -rf dist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 重载服务
 | 
					# 重载服务
 | 
				
			||||||
ssh $host "pm2 reload webp"
 | 
					ssh $host "systemctl restart webp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# 删除旧文件
 | 
					# 删除旧文件
 | 
				
			||||||
ssh $host "rm ~/webp/main_old"
 | 
					ssh $host "rm ~/webp/main_old"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 设为系统服务
 | 
				
			||||||
 | 
					# sudo cp webp.service /etc/systemd/system/webp.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 设置日志轮转
 | 
				
			||||||
 | 
					# sudo cp webp.logrotate /etc/logrotate.d/webp
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								webp.logrotate
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								webp.logrotate
									
									
									
									
									
										Normal file
									
								
							@@ -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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										17
									
								
								webp.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								webp.service
									
									
									
									
									
										Normal file
									
								
							@@ -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
 | 
				
			||||||
		Reference in New Issue
	
	Block a user