.cursor/skills/runnable-background-processes/SKILL.md
Регистрация фоновых процессов через pior/runnable. Используй при добавлении Telegram bot и других воркеров в kb-server.
npx skillsauth add strider2038/knowledge-db runnable-background-processesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Фоновые процессы управляются pior/runnable через runnable.Manager.
type Runnable interface {
Run(context.Context) error
}
Процесс блокируется в Run до отмены контекста. При shutdown Manager отменяет контекст.
func (b *TelegramBot) Run(ctx context.Context) error {
logger := clog.FromContext(ctx)
logger.Info("telegram bot: started")
defer logger.Info("telegram bot: stopped")
for {
select {
case <-ctx.Done():
return nil
default:
b.poll(ctx)
}
}
}
m.Register(
runnable.HTTPServer(srv).ShutdownTimeout(30*time.Second),
runnable.WithName("telegram-bot", bot), // или обёртка с логгером в контексте
)
При регистрации — обеспечить, чтобы в контекст воркера передавался логгер с атрибутом runnable=<name> (для фильтрации в логах).
Не использовать time.Sleep — он не реагирует на отмену контекста. При shutdown процесс будет ждать полный интервал вместо немедленной остановки.
Использовать select с ctx.Done() и time.After:
select {
case <-ctx.Done():
return nil
case <-time.After(5 * time.Second):
// продолжаем работу
}
Только clog.FromContext(ctx). Запрещён прямой вызов slog.Info, slog.Warn — иначе нет атрибута runnable в логах.
// Правильно
logger := clog.FromContext(ctx)
logger.Warn("poll failed", slog.String("error", err.Error()))
// Неправильно
slog.Warn("poll failed", ...)
development
Knowledge base layout and node format for knowledge-db. Use when creating or editing KB markdown files. Root path placeholder {{DATA_PATH}}.
development
Frontend web/ (React, TypeScript, Vite). Используй при работе с web/src/**/*.tsx, web/src/**/*.ts.
testing
Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving.
data-ai
Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.