| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 22:21:26 -05:00
										 |  |  | // Public node modules
 | 
					
						
							|  |  |  | const rimraf = require('rimraf'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  | // Logger.
 | 
					
						
							|  |  |  | const logger = require('strapi-utils').logger; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = (scope, success, error) => { | 
					
						
							| 
									
										
										
										
											2018-09-12 22:03:31 -05:00
										 |  |  |   const Redis = require(`ioredis`); | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  |   const redis = new Redis({ | 
					
						
							| 
									
										
										
										
											2018-01-17 09:14:34 +01:00
										 |  |  |     port: scope.database.settings.port, | 
					
						
							|  |  |  |     host: scope.database.settings.host, | 
					
						
							| 
									
										
										
										
											2018-01-17 10:13:23 +01:00
										 |  |  |     password: scope.database.settings.password, | 
					
						
							| 
									
										
										
										
											2018-01-17 09:14:34 +01:00
										 |  |  |     db: scope.database.settings.database | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   redis.connect((err) => { | 
					
						
							|  |  |  |     redis.disconnect(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (err) { | 
					
						
							| 
									
										
										
										
											2018-01-10 18:08:43 +01:00
										 |  |  |       logger.warn('Database connection has failed! Make sure your database is running.'); | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  |       return error(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 18:08:43 +01:00
										 |  |  |     logger.info('The app has been connected to the database successfully!'); | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 23:06:53 -05:00
										 |  |  |     rimraf(scope.tmpPath, (err) => { | 
					
						
							|  |  |  |       if (err) { | 
					
						
							|  |  |  |         console.log(`Error removing connection test folder: ${scope.tmpPath}`); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       logger.info('Copying the dashboard...'); | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-12 23:06:53 -05:00
										 |  |  |       success(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-01-10 15:31:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }; |