操作本地运行

运维部署 社区

技能解读

当前原文的自动摘译,尚未人工审校。

先决条件(在任何操作之前运行)

验证 Docker 正在运行: 检查端口可用性: 验证 Ruby 和 Bundler 是否可用:

发现

阅读项目的docker-compose.yml(或compose.yaml)以识别可用的服务。常见服务包括: web 或 app — Rails 应用程序 postgres 或 db — PostgreSQL 数据库 worker — Solid Queue 后台工作程序 css — Tailwind CSS 监视进程

开始(全栈)

启动所有 Docker Compose 服务和 Rails 应用程序。启动基础设施服务(PostgreSQL 等): 等待 PostgreSQL(最多 30 秒): 创建并迁移数据库(如果需要): 通过 bin/dev (Procfile.dev) 或 Docker Compose 启动完整堆栈:

启动服务(仅限基础设施)

仅启动基础设施服务(数据库、缓存),无需 Rails 应用程序。等待准备就绪:

start-app(仅限 Rails 应用程序,假设服务正在运行)

在后台运行。核实:

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
运维部署
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@tomevault-io · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需手动接入
是否需要外部接口密钥
不需要
兼容的系统
Docker
运行环境要求
Docker
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
允许外网请求
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# Ops: Run Local

Manage the local Docker Compose development environment.

**Argument**: `$ARGUMENTS` — `start`, `stop`, `restart`, `status`, `start-app`, `start-services` (default: `start`)

## Prerequisites (run before any operation)

1. Verify Docker is running:
   ```bash
   docker info > /dev/null 2>&1 && echo "Docker OK" || echo "ERROR: Docker is not running — start Docker Desktop"
   ```

2. Check port availability:
   ```bash
   lsof -i :3000 2>/dev/null | grep LISTEN
   lsof -i :5432 2>/dev/null | grep LISTEN
   ```

3. Verify Ruby and Bundler are available:
   ```bash
   ruby --version && bundle --version
   ```

## Discovery

Read the project's `docker-compose.yml` (or `compose.yaml`) to identify available services. Common services include:

- `web` or `app` — the Rails application
- `postgres` or `db` — PostgreSQL database
- `worker` — Solid Queue background worker
- `css` — Tailwind CSS watch process

Read `Procfile.dev` if it exists — it defines the local development process manager configuration (typically run via `bin/dev`).

Read `config/database.yml` to understand which databases need to exist locally.

## Operations

### start (full stack)

Start all Docker Compose services and the Rails application.

1. **Start infrastructure services** (PostgreSQL, etc.):
   ```bash
   docker compose up -d postgres
   ```

2. **Wait for PostgreSQL** (up to 30 seconds):
   ```bash
   for i in $(seq 1 30); do
     docker compose exec -T postgres pg_isready -U postgres > /dev/null 2>&1 && echo "PostgreSQL ready" && break
     sleep 1
   done
   ```

3. **Create and migrate databases** (if needed):
   ```bash
   bin/rails db:prepare
   ```

4. **Start the full stack** via `bin/dev` (Procfile.dev) or Docker Compose:
   ```bash
   # Option A: Procfile.dev (preferred — starts web, worker, CSS watcher)
   bin/dev
   ```
   Run this in the background using the Bash tool with `run_in_background: true`.

   ```bash
   # Option B: Docker Compose (if all services are containerized)
   docker compose up -d
   ```

5. **Wait for Rails** (up to 60 seconds):
   ```bash
   for i in $(seq 1 60); do
     curl -sf http://localhost:3000/up > /dev/null 2>&1 && echo "Rails ready" && break
     sleep 1
   done
   ```

6. Report status table.

### start-services (infrastructure only)

Start only infrastructure services (database, cache) without the Rails app.

```bash
docker compose up -d postgres
```

Wait for readiness:
```bash
for i in $(seq 1 30); do
  docker compose exec -T postgres pg_isready -U postgres > /dev/null 2>&1 && echo "PostgreSQL ready" && break
  sleep 1
done
```

### start-app (Rails app only, assumes services are running)

```bash
bin/dev
```

Run in background. Verify:
```bash
for i in $(seq 1 60); do
  curl -sf http://localhost:3000/up > /dev/null 2>&1 && echo "Rails ready" && break
  sleep 1
done
```

### stop

Stop all local services.

```bash
# Stop Rails processes (bin/dev uses foreman which spawns child processes)
lsof -ti :3000 | xargs kill -9 2>/dev/null || echo "No Rails process on :3000"

# Stop Docker Compose services
docker compose down
```

### restart

1. Run **stop** (above).
2. Wait 2 seconds: `sleep 2`
3. Run **start** (above).
4. Verify all services respond.

### status

Check what is currently running and responsive.

```bash
echo "=== Port Check ==="
echo -n "Rails    :3000 — "; lsof -i :3000 2>/dev/null | grep LISTEN > /dev/null && echo "LISTENING" || echo "NOT LISTENING"
echo -n "Postgres :5432 — "; lsof -i :5432 2>/dev/null | grep LISTEN > /dev/null && echo "LISTENING" || echo "NOT LISTENING"

echo ""
echo "=== Health Check ==="
echo -n "Rails /up — "; curl -sf -o /dev/null -w "HTTP %{http_code} in %{time_total}s" http://localhost:3000/up 2>/dev/null || echo "UNREACHABLE"

echo ""
echo "=== Docker Compose ==="
docker compose ps 2>/dev/null || echo "No Docker Compose services running"

echo ""
echo "=== Solid Queue Worker ==="
bin/rails runner "puts SolidQueue::Process.where('last_heartbeat_at > ?', 5.minutes.ago).count.to_s + ' active workers'" 2>/dev/null || echo "Cannot query Solid Queue (app may not be running)"
```

Report results as a table:

| Service | Port | Listening | Responsive |
|---------|------|-----------|------------|
| Rails (web) | 3000 | YES/NO | YES/NO |
| PostgreSQL | 5432 | YES/NO | N/A |
| Solid Queue worker | N/A | N/A | YES/NO (heartbeat) |

---
> Source: [CodySwannGT/lisa](https://github.com/CodySwannGT/lisa) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。