File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,11 +77,12 @@ RUN mkdir -p /app/tmp/pids /app/tmp/cache /app/tmp/sockets /app/log && \
7777USER rails:rails
7878
7979# Expose port (Railway sets PORT=8080 by default)
80- EXPOSE 3000
80+ EXPOSE 8080
8181
8282# Health check (uses PORT env variable to match runtime configuration)
83- HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
84- CMD curl -f http://localhost:${PORT:-3000}/up || exit 1
83+ # Note: Railway has its own health check system, but this is useful for local testing
84+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
85+ CMD curl -f http://localhost:${PORT:-8080}/up || exit 1
8586
8687# Entry point for database migration
8788COPY --chown=rails:rails deploy/scripts/docker-entrypoint.sh /usr/local/bin/
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ class HealthController < ActionController ::API
4+ # Simple health check that doesn't check database
5+ def index
6+ render json : {
7+ status : 'ok' ,
8+ timestamp : Time . current . iso8601 ,
9+ environment : Rails . env
10+ }
11+ end
12+
13+ # Detailed health check with database verification
14+ def show
15+ database_status = check_database
16+
17+ render json : {
18+ status : database_status ? 'ok' : 'degraded' ,
19+ timestamp : Time . current . iso8601 ,
20+ environment : Rails . env ,
21+ database : database_status ? 'connected' : 'disconnected'
22+ } , status : database_status ? :ok : :service_unavailable
23+ end
24+
25+ private
26+
27+ def check_database
28+ ActiveRecord ::Base . connection . execute ( 'SELECT 1' )
29+ true
30+ rescue StandardError => e
31+ Rails . logger . error "Health check database error: #{ e . message } "
32+ false
33+ end
34+ end
Original file line number Diff line number Diff line change 77
88 # Health check endpoints
99 get 'up' => 'rails/health#show' , as : :rails_health_check
10- get 'health' => 'rails/health#show'
10+ get 'health' => 'health#index' # Simple health without DB check
11+ get 'health/detailed' => 'health#show' # Detailed health with DB check
1112
1213 # SEO - Sitemap
1314 get 'sitemap.xml' , to : 'sitemap#index' , defaults : { format : 'xml' }
Original file line number Diff line number Diff line change 4949
5050# Skip preload in production - Puma will handle it
5151echo " [4/4] Starting application server..." >&2
52+ echo " → Port: ${PORT:- 3000} " >&2
53+ echo " → Environment: ${RAILS_ENV:- development} " >&2
54+ echo " → Workers: ${WEB_CONCURRENCY:- 2} " >&2
5255echo " ========================================" >&2
5356
5457# Execute the main command
You can’t perform that action at this time.
0 commit comments