Class: Clacky::DeployTools::ListServices
- Inherits:
-
Object
- Object
- Clacky::DeployTools::ListServices
- Defined in:
- lib/clacky/default_skills/deploy/tools/list_services.rb
Overview
List Railway services for the linked project. Uses RAILWAY_TOKEN passed through environment — no clackycli wrapper needed.
NOTE: In the new deploy flow, service discovery is primarily done via the Clacky Deploy API (deploy/services endpoint). This tool is kept as a fallback for detecting the main service name via ‘railway service list`.
Class Method Summary collapse
-
.execute(platform_token:) ⇒ Hash
List services for the current Railway project.
Class Method Details
.execute(platform_token:) ⇒ Hash
List services for the current Railway project.
}
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/clacky/default_skills/deploy/tools/list_services.rb', line 25 def self.execute(platform_token:) if platform_token.nil? || platform_token.strip.empty? return { success: false, error: "platform_token is required" } end env = ENV.to_h.merge("RAILWAY_TOKEN" => platform_token) out, err, status = Open3.capture3(env, "railway status --json") unless status.success? return { success: false, error: "railway service list failed (exit #{status.exitstatus})", details: err } end info = JSON.parse(out) services = info["services"] || [] main_svc = services.find do |s| name = s["name"].to_s.downcase !%w[postgres postgresql mysql redis].any? { |db| name.include?(db) } end db_svc = services.find do |s| name = s["name"].to_s.downcase %w[postgres postgresql mysql].any? { |db| name.include?(db) } end { success: true, services: services, main_service: main_svc, db_service: db_svc } rescue JSON::ParserError => e { success: false, error: "Failed to parse service list: #{e.}", raw: out.to_s[0, 200] } rescue => e { success: false, error: "Unexpected error: #{e.}" } end |