Add health check script and improve Redis debugging
This commit is contained in:
		| @@ -5,7 +5,7 @@ | |||||||
|   "description": "Open-source collaborative wiki and documentation platform. A modern alternative to Confluence and Notion with real-time collaboration, diagram support, and multilingual capabilities.", |   "description": "Open-source collaborative wiki and documentation platform. A modern alternative to Confluence and Notion with real-time collaboration, diagram support, and multilingual capabilities.", | ||||||
|   "tagline": "Collaborative wiki and documentation platform", |   "tagline": "Collaborative wiki and documentation platform", | ||||||
|   "version": "1.0.0", |   "version": "1.0.0", | ||||||
|   "healthCheckPath": "/api/health", |   "healthCheckPath": "/", | ||||||
|   "httpPort": 3000, |   "httpPort": 3000, | ||||||
|   "addons": { |   "addons": { | ||||||
|     "postgresql": {}, |     "postgresql": {}, | ||||||
|   | |||||||
| @@ -22,10 +22,11 @@ RUN mkdir -p /tmp/data /app/data && \ | |||||||
|  |  | ||||||
| # Copy startup scripts | # Copy startup scripts | ||||||
| COPY start.sh /app/code/ | COPY start.sh /app/code/ | ||||||
|  | COPY healthcheck.js /app/code/ | ||||||
| COPY nginx.conf /etc/nginx/sites-available/default | COPY nginx.conf /etc/nginx/sites-available/default | ||||||
|  |  | ||||||
| # Make scripts executable | # Make scripts executable | ||||||
| RUN chmod +x /app/code/start.sh | RUN chmod +x /app/code/start.sh /app/code/healthcheck.js | ||||||
|  |  | ||||||
| # Install supervisord and netcat for process management and connectivity checks | # Install supervisord and netcat for process management and connectivity checks | ||||||
| RUN apt-get update && \ | RUN apt-get update && \ | ||||||
|   | |||||||
							
								
								
									
										34
									
								
								healthcheck.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								healthcheck.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | #!/usr/bin/env node | ||||||
|  |  | ||||||
|  | const http = require('http'); | ||||||
|  |  | ||||||
|  | // Simple health check that attempts to connect to the app | ||||||
|  | const options = { | ||||||
|  |   hostname: 'localhost', | ||||||
|  |   port: 3001, | ||||||
|  |   path: '/', | ||||||
|  |   method: 'GET', | ||||||
|  |   timeout: 5000 | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | const req = http.request(options, (res) => { | ||||||
|  |   console.log(`Health check: ${res.statusCode}`); | ||||||
|  |   if (res.statusCode === 200) { | ||||||
|  |     process.exit(0); | ||||||
|  |   } else { | ||||||
|  |     process.exit(1); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | req.on('error', (err) => { | ||||||
|  |   console.error('Health check failed:', err.message); | ||||||
|  |   process.exit(1); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | req.on('timeout', () => { | ||||||
|  |   console.error('Health check timeout'); | ||||||
|  |   req.abort(); | ||||||
|  |   process.exit(1); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | req.end(); | ||||||
							
								
								
									
										6
									
								
								start.sh
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								start.sh
									
									
									
									
									
								
							| @@ -55,10 +55,12 @@ if [ -n "${CLOUDRON_REDIS_URL}" ]; then | |||||||
|     export REDIS_PORT="${REDIS_PORT}" |     export REDIS_PORT="${REDIS_PORT}" | ||||||
|     export REDIS_PASSWORD="${REDIS_PASSWORD}" |     export REDIS_PASSWORD="${REDIS_PASSWORD}" | ||||||
|      |      | ||||||
|     # Also export the full URL in case it's needed |     # Also export the full URL in case it's needed - try different formats | ||||||
|     export REDIS_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/0" |     export REDIS_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}" | ||||||
|  |     export REDIS_DB="0" | ||||||
|      |      | ||||||
|     echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}" |     echo "=> Redis configured: host=${REDIS_HOST}, port=${REDIS_PORT}" | ||||||
|  |     echo "=> Final Redis URL: ${REDIS_URL}" | ||||||
| else | else | ||||||
|     echo "=> Warning: Redis URL not provided" |     echo "=> Warning: Redis URL not provided" | ||||||
|     # Set dummy Redis URL to prevent validation errors |     # Set dummy Redis URL to prevent validation errors | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user