railway-service

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Railway Service Management

Railway 服务管理

Check status, update properties, and advanced service creation.
检查状态、更新属性,以及高级服务创建。

When to Use

使用场景

  • User asks about service status, health, or deployments
  • User asks "is my service deployed?"
  • User wants to rename a service or change service icon
  • User wants to link a different service
  • User wants to deploy a Docker image as a new service (advanced)
Note: For creating services with local code (the common case), prefer the railway-new skill which handles project setup, scaffolding, and service creation together.
For GitHub repo sources: Use railway-new skill to create empty service, then railway-environment skill to configure source.repo via staged changes API.
  • 用户询问服务状态、健康状况或部署情况
  • 用户询问“我的服务是否已部署?”
  • 用户想要重命名服务或更改服务图标
  • 用户想要关联其他服务
  • 用户想要将Docker镜像部署为新服务(高级操作)
注意: 对于使用本地代码创建服务的常见场景,优先使用railway-new技能,它会一并处理项目设置、脚手架搭建和服务创建。
对于GitHub仓库源: 使用railway-new技能创建空服务,然后使用railway-environment技能通过分阶段变更API配置source.repo。

Create Service

创建服务

Create a new service via GraphQL API. There is no CLI command for this.
通过GraphQL API创建新服务。目前没有对应的CLI命令。

Get Context

获取上下文

bash
railway status --json
Extract:
  • project.id
    - for creating the service
  • environment.id
    - for staging the instance config
bash
railway status --json
提取以下信息:
  • project.id
    - 用于创建服务
  • environment.id
    - 用于暂存实例配置

Create Service Mutation

创建服务的Mutation

graphql
mutation serviceCreate($input: ServiceCreateInput!) {
  serviceCreate(input: $input) {
    id
    name
  }
}
graphql
mutation serviceCreate($input: ServiceCreateInput!) {
  serviceCreate(input: $input) {
    id
    name
  }
}

ServiceCreateInput Fields

ServiceCreateInput 字段

FieldTypeDescription
projectId
String!Project ID (required)
name
StringService name (auto-generated if omitted)
source.image
StringDocker image (e.g.,
nginx:latest
)
source.repo
StringGitHub repo (e.g.,
user/repo
)
branch
StringGit branch for repo source
environmentId
StringIf set and is a fork, only creates in that env
FieldType说明
projectId
String!项目ID(必填)
name
String服务名称(若省略则自动生成)
source.image
StringDocker镜像(例如:
nginx:latest
source.repo
StringGitHub仓库(例如:
user/repo
branch
String仓库源的Git分支
environmentId
String若设置且为分支环境,仅在该环境中创建服务

Example: Create empty service

示例:创建空服务

bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation createService($input: ServiceCreateInput!) {
    serviceCreate(input: $input) { id name }
  }' \
  '{"input": {"projectId": "PROJECT_ID"}}'
SCRIPT
bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation createService($input: ServiceCreateInput!) {
    serviceCreate(input: $input) { id name }
  }' \
  '{"input": {"projectId": "PROJECT_ID"}}'
SCRIPT

Example: Create service with image

示例:使用镜像创建服务

bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation createService($input: ServiceCreateInput!) {
    serviceCreate(input: $input) { id name }
  }' \
  '{"input": {"projectId": "PROJECT_ID", "name": "my-service", "source": {"image": "nginx:latest"}}}'
SCRIPT
bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation createService($input: ServiceCreateInput!) {
    serviceCreate(input: $input) { id name }
  }' \
  '{"input": {"projectId": "PROJECT_ID", "name": "my-service", "source": {"image": "nginx:latest"}}}'
SCRIPT

Connecting a GitHub Repo

关联GitHub仓库

Do NOT use serviceCreate with source.repo - use staged changes API instead.
Flow:
  1. Create empty service:
    serviceCreate(input: {projectId: "...", name: "my-service"})
  2. Use railway-environment skill to configure source via staged changes API
  3. Apply to trigger deployment
请勿使用serviceCreate的source.repo参数 - 请改用分阶段变更API。
流程:
  1. 创建空服务:
    serviceCreate(input: {projectId: "...", name: "my-service"})
  2. 使用railway-environment技能通过分阶段变更API配置源
  3. 应用变更以触发部署

After Creating: Configure Instance

创建后:配置实例

Use railway-environment skill to configure the service instance:
json
{
  "services": {
    "<serviceId>": {
      "isCreated": true,
      "source": { "image": "nginx:latest" },
      "variables": {
        "PORT": { "value": "8080" }
      }
    }
  }
}
Critical: Always include
isCreated: true
for new service instances.
Then use railway-environment skill to apply and deploy.
使用railway-environment技能配置服务实例:
json
{
  "services": {
    "<serviceId>": {
      "isCreated": true,
      "source": { "image": "nginx:latest" },
      "variables": {
        "PORT": { "value": "8080" }
      }
    }
  }
}
关键注意事项: 对于新服务实例,务必包含
isCreated: true
然后使用railway-environment技能应用变更并部署。

Check Service Status

检查服务状态

bash
railway service status --json
Returns current deployment status for the linked service.
bash
railway service status --json
返回当前关联服务的部署状态。

Deployment History

部署历史

bash
railway deployment list --json --limit 5
bash
railway deployment list --json --limit 5

Present Status

状态展示

Show:
  • Service: name and current status
  • Latest Deployment: status (SUCCESS, FAILED, DEPLOYING, CRASHED, etc.)
  • Deployed At: when the current deployment went live
  • Recent Deployments: last 3-5 with status and timestamps
展示以下信息:
  • 服务:名称和当前状态
  • 最新部署:状态(SUCCESS、FAILED、DEPLOYING、CRASHED等)
  • 部署时间:当前部署上线的时间
  • 近期部署:最近3-5次部署的状态和时间戳

Deployment Statuses

部署状态说明

StatusMeaning
SUCCESSDeployed and running
FAILEDBuild or deploy failed
DEPLOYINGCurrently deploying
BUILDINGBuild in progress
CRASHEDRuntime crash
REMOVEDDeployment removed
Status含义
SUCCESS已部署且运行中
FAILED构建或部署失败
DEPLOYING正在部署中
BUILDING构建进行中
CRASHED运行时崩溃
REMOVED部署已移除

Update Service

更新服务

Update service name or icon via GraphQL API.
通过GraphQL API更新服务名称或图标。

Get Service ID

获取服务ID

bash
railway status --json
Extract
service.id
from the response.
bash
railway status --json
从响应中提取
service.id

Update Name

更新名称

bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation updateService($id: String!, $input: ServiceUpdateInput!) {
    serviceUpdate(id: $id, input: $input) { id name }
  }' \
  '{"id": "SERVICE_ID", "input": {"name": "new-name"}}'
SCRIPT
bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation updateService($id: String!, $input: ServiceUpdateInput!) {
    serviceUpdate(id: $id, input: $input) { id name }
  }' \
  '{"id": "SERVICE_ID", "input": {"name": "new-name"}}'
SCRIPT

Update Icon

更新图标

Icons can be image URLs or animated GIFs.
TypeExample
Image URL
"icon": "https://example.com/logo.png"
Animated GIF
"icon": "https://example.com/animated.gif"
Devicons
"icon": "https://devicons.railway.app/github"
Railway Devicons: Query
https://devicons.railway.app/{query}
for common developer icons (e.g.,
github
,
postgres
,
redis
,
nodejs
). Browse all at https://devicons.railway.app
bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation updateService($id: String!, $input: ServiceUpdateInput!) {
    serviceUpdate(id: $id, input: $input) { id icon }
  }' \
  '{"id": "SERVICE_ID", "input": {"icon": "https://devicons.railway.app/github"}}'
SCRIPT
图标可以是图片URL或动画GIF。
类型示例
图片URL
"icon": "https://example.com/logo.png"
动画GIF
"icon": "https://example.com/animated.gif"
Devicons
"icon": "https://devicons.railway.app/github"
Railway Devicons: 查询
https://devicons.railway.app/{query}
获取常见开发者图标(例如
github
postgres
redis
nodejs
)。可访问https://devicons.railway.app浏览全部图标。
bash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation updateService($id: String!, $input: ServiceUpdateInput!) {
    serviceUpdate(id: $id, input: $input) { id icon }
  }' \
  '{"id": "SERVICE_ID", "input": {"icon": "https://devicons.railway.app/github"}}'
SCRIPT

ServiceUpdateInput Fields

ServiceUpdateInput 字段

FieldTypeDescription
name
StringService name
icon
StringEmoji or image URL (including animated GIFs)
FieldType说明
name
String服务名称
icon
String表情符号或图片URL(包括动画GIF)

Link Service

关联服务

Switch the linked service for the current directory:
bash
railway service link
Or specify directly:
bash
railway service link <service-name>
切换当前目录关联的服务:
bash
railway service link
或直接指定服务名称:
bash
railway service link <service-name>

Composability

组合使用

  • Create service with local code: Use railway-new skill (handles scaffolding + creation)
  • Configure service: Use railway-environment skill (variables, commands, image, etc.)
  • Delete service: Use railway-environment skill with
    isDeleted: true
  • Apply changes: Use railway-environment skill
  • View logs: Use railway-deployment skill
  • Deploy local code: Use railway-deploy skill
  • 使用本地代码创建服务:使用railway-new技能(处理脚手架搭建+服务创建)
  • 配置服务:使用railway-environment技能(变量、命令、镜像等)
  • 删除服务:使用railway-environment技能并设置
    isDeleted: true
  • 应用变更:使用railway-environment技能
  • 查看日志:使用railway-deployment技能
  • 部署本地代码:使用railway-deploy技能

Error Handling

错误处理

No Service Linked

未关联服务

No service linked. Run `railway service link` to link a service.
未关联服务。请运行`railway service link`关联一个服务。

No Deployments

无部署记录

Service exists but has no deployments yet. Deploy with `railway up`.
服务已存在,但尚未进行任何部署。请使用`railway up`进行部署。

Service Not Found

服务未找到

Service "foo" not found. Check available services with `railway status`.
未找到服务"foo"。请使用`railway status`查看可用服务。

Project Not Found

项目未找到

User may not be in a linked project. Check
railway status
.
用户可能未处于关联项目目录中。请检查
railway status

Permission Denied

权限不足

User needs at least DEVELOPER role to create services.
用户至少需要DEVELOPER角色才能创建服务。

Invalid Image

镜像无效

Docker image must be accessible (public or with registry credentials).
Docker镜像必须可访问(公开镜像或已配置仓库凭证)。