Skip to content

[Worker] deploy.ymlのプロセス停止ロジックを改善 #178

Description

@wisteriahuman

Tracked by #173

概要

デプロイ時に古いdaemon.tsプロセスが残り、2重実行が発生していた。
これが2025-12-29のweekly-resetエラー(11件)の根本原因

発見したプロセス状況

17043 (PPID=1) ← 孤立プロセス(古いデプロイの残骸)
  └── 17193 - daemon.ts 実行中

17154 (pm2管理)
  └── 17181
      └── 17192 - daemon.ts 実行中

原因

現在のpkillコマンドが子プロセス(tsx経由のnode)を残している。

現在のコード

pkill -f "src/daemon.ts" || true
sleep 2
pkill -9 -f "src/daemon.ts" || true

対応案

# tsx経由のnodeプロセスも含めてkill
pkill -f "daemon.ts" || true
pkill -f "tsx.*daemon" || true
sleep 2
pkill -9 -f "daemon.ts" || true
pkill -9 -f "tsx.*daemon" || true
# 確認
if pgrep -f "daemon.ts" > /dev/null; then
  echo "Warning: daemon.ts processes still running"
  exit 1
fi

関連ファイル

  • .github/workflows/deploy.yml

影響

2重実行により以下が発生:

  • ユニーク制約違反(同じレコードを2回INSERT)
  • API過負荷(2倍のリクエスト)
  • リソース競合

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend(worker)apps/worker の実装bug不具合、不具合かもしれない事象chore開発環境の改善、依存関係の更新

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions