| 
									
										
										
										
											2019-03-09 01:06:39 +01:00
										 |  |  | const request = require('request-promise-native'); | 
					
						
							| 
									
										
										
										
											2019-03-06 19:19:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-12 11:41:38 +01:00
										 |  |  | module.exports = function(initTime = 200) { | 
					
						
							| 
									
										
										
										
											2019-03-06 19:19:33 +01:00
										 |  |  |   const ping = async () => { | 
					
						
							|  |  |  |     return new Promise((resolve, reject) => { | 
					
						
							|  |  |  |       // ping _health
 | 
					
						
							| 
									
										
										
										
											2019-03-09 01:06:39 +01:00
										 |  |  |       request({ | 
					
						
							|  |  |  |         url: 'http://localhost:1337/_health', | 
					
						
							|  |  |  |         method: 'HEAD', | 
					
						
							|  |  |  |         mode: 'no-cors', | 
					
						
							|  |  |  |         json: true, | 
					
						
							|  |  |  |         headers: { | 
					
						
							|  |  |  |           'Content-Type': 'application/json', | 
					
						
							|  |  |  |           'Keep-Alive': false, | 
					
						
							| 
									
										
										
										
											2019-03-06 19:19:33 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2019-03-09 01:06:39 +01:00
										 |  |  |       }).then(resolve, reject); | 
					
						
							|  |  |  |     }).catch(() => { | 
					
						
							| 
									
										
										
										
											2019-03-12 11:41:38 +01:00
										 |  |  |       return new Promise(resolve => setTimeout(resolve, 200)).then(ping); | 
					
						
							| 
									
										
										
										
											2019-03-06 19:19:33 +01:00
										 |  |  |     }); | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2018-05-21 17:04:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-06 19:19:33 +01:00
										 |  |  |   return new Promise(resolve => setTimeout(resolve, initTime)).then(ping); | 
					
						
							| 
									
										
										
										
											2018-05-21 17:04:25 +02:00
										 |  |  | }; |