Browse Source
			
			
			Merge pull request #89 from Saibamen/more_info_in_server_logs
			
				More info in server logs
			
			
				pull/99/head
			
			
		 
		
			
				
					
						 Louis Lam
					
					4 years ago
						Louis Lam
					
					4 years ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 4AEE18F83AFDEB23
						
					
				
			
		
		
		
	
		
			
				 1 changed files with 
6 additions and 
2 deletions
			 
			
		 
		
			
				- 
					
					
					 
					server/model/monitor.js
				
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -48,8 +48,6 @@ class Monitor extends BeanModel { | 
			
		
	
		
		
			
				
					|  |  |         let previousBeat = null; |  |  |         let previousBeat = null; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         const beat = async () => { |  |  |         const beat = async () => { | 
			
		
	
		
		
			
				
					|  |  |             console.log(`Monitor ${this.id}: Heartbeat`) |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             if (! previousBeat) { |  |  |             if (! previousBeat) { | 
			
		
	
		
		
			
				
					|  |  |                 previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [ |  |  |                 previousBeat = await R.findOne("heartbeat", " monitor_id = ? ORDER BY time DESC", [ | 
			
		
	
		
		
			
				
					|  |  |                     this.id |  |  |                     this.id | 
			
		
	
	
		
		
			
				
					|  | @ -145,6 +143,12 @@ class Monitor extends BeanModel { | 
			
		
	
		
		
			
				
					|  |  |                 bean.important = false; |  |  |                 bean.important = false; | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (bean.status === 1) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 console.info(`Monitor #${this.id} '${this.name}': Successful Response: ${bean.ping} ms | Interval: ${this.interval} seconds | Type: ${this.type}`) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 console.warn(`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Type: ${this.type}`) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             io.to(this.user_id).emit("heartbeat", bean.toJSON()); |  |  |             io.to(this.user_id).emit("heartbeat", bean.toJSON()); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             await R.store(bean) |  |  |             await R.store(bean) | 
			
		
	
	
		
		
			
				
					|  | 
 |