railway-service
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRailway 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 --jsonExtract:
- - for creating the service
project.id - - for staging the instance config
environment.id
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 字段
| Field | Type | Description |
|---|---|---|
| String! | Project ID (required) |
| String | Service name (auto-generated if omitted) |
| String | Docker image (e.g., |
| String | GitHub repo (e.g., |
| String | Git branch for repo source |
| String | If set and is a fork, only creates in that env |
| Field | Type | 说明 |
|---|---|---|
| String! | 项目ID(必填) |
| String | 服务名称(若省略则自动生成) |
| String | Docker镜像(例如: |
| String | GitHub仓库(例如: |
| String | 仓库源的Git分支 |
| 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"}}'
SCRIPTbash
bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
'mutation createService($input: ServiceCreateInput!) {
serviceCreate(input: $input) { id name }
}' \
'{"input": {"projectId": "PROJECT_ID"}}'
SCRIPTExample: 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"}}}'
SCRIPTbash
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"}}}'
SCRIPTConnecting a GitHub Repo
关联GitHub仓库
Do NOT use serviceCreate with source.repo - use staged changes API instead.
Flow:
- Create empty service:
serviceCreate(input: {projectId: "...", name: "my-service"}) - Use railway-environment skill to configure source via staged changes API
- Apply to trigger deployment
请勿使用serviceCreate的source.repo参数 - 请改用分阶段变更API。
流程:
- 创建空服务:
serviceCreate(input: {projectId: "...", name: "my-service"}) - 使用railway-environment技能通过分阶段变更API配置源
- 应用变更以触发部署
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 for new service instances.
isCreated: trueThen 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 --jsonReturns current deployment status for the linked service.
bash
railway service status --json返回当前关联服务的部署状态。
Deployment History
部署历史
bash
railway deployment list --json --limit 5bash
railway deployment list --json --limit 5Present 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
部署状态说明
| Status | Meaning |
|---|---|
| SUCCESS | Deployed and running |
| FAILED | Build or deploy failed |
| DEPLOYING | Currently deploying |
| BUILDING | Build in progress |
| CRASHED | Runtime crash |
| REMOVED | Deployment 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 --jsonExtract from the response.
service.idbash
railway status --json从响应中提取。
service.idUpdate 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"}}'
SCRIPTbash
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"}}'
SCRIPTUpdate Icon
更新图标
Icons can be image URLs or animated GIFs.
| Type | Example |
|---|---|
| Image URL | |
| Animated GIF | |
| Devicons | |
Railway Devicons: Query for common developer icons (e.g., , , , ). Browse all at https://devicons.railway.app
https://devicons.railway.app/{query}githubpostgresredisnodejsbash
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 | |
| 动画GIF | |
| Devicons | |
Railway Devicons: 查询获取常见开发者图标(例如、、、)。可访问https://devicons.railway.app浏览全部图标。
https://devicons.railway.app/{query}githubpostgresredisnodejsbash
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"}}'
SCRIPTServiceUpdateInput Fields
ServiceUpdateInput 字段
| Field | Type | Description |
|---|---|---|
| String | Service name |
| String | Emoji or image URL (including animated GIFs) |
| Field | Type | 说明 |
|---|---|---|
| String | 服务名称 |
| String | 表情符号或图片URL(包括动画GIF) |
Link Service
关联服务
Switch the linked service for the current directory:
bash
railway service linkOr 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 statusPermission Denied
权限不足
User needs at least DEVELOPER role to create services.
用户至少需要DEVELOPER角色才能创建服务。
Invalid Image
镜像无效
Docker image must be accessible (public or with registry credentials).
Docker镜像必须可访问(公开镜像或已配置仓库凭证)。