Agent skill
background-service-manager
Create and manage long-running background processes with start/stop/status controls, logging, and monitoring. Use for batch processing jobs, data pipelines, continuous services, or any long-running tasks.
Install this agent skill to your Project
npx add-skill https://github.com/vamseeachanta/workspace-hub/tree/main/.claude/skills/operations/devtools/background-service-manager
SKILL.md
Background Service Manager
Overview
This skill creates service management scripts for long-running background processes. Includes start/stop controls, PID management, log rotation, status monitoring, and graceful shutdown handling.
Quick Start
- Create service script - Copy the basic template below
- Customize command - Set
SERVICE_CMDto your process - Make executable -
chmod +x service.sh - Start service -
./service.sh start - Monitor -
./service.sh statusor./service.sh logs
#!/bin/bash
# Quick service wrapper
SERVICE_NAME="myservice"
PID_FILE="/tmp/${SERVICE_NAME}.pid"
LOG_FILE="/tmp/${SERVICE_NAME}.log"
SERVICE_CMD="python3 ./worker.py"
case "$1" in
start)
nohup $SERVICE_CMD >> "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "Started (PID: $!)"
;;
stop)
[ -f "$PID_FILE" ] && kill $(cat "$PID_FILE") && rm "$PID_FILE"
;;
status)
[ -f "$PID_FILE" ] && kill -0 $(cat "$PID_FILE") 2>/dev/null && echo "Running" || echo "Stopped"
;;
*) echo "Usage: $0 {start|stop|status}" ;;
esac
When to Use
- Running long batch processing jobs (extraction, embedding, ETL)
- Managing continuous data pipelines
- Background workers for queues or scheduled tasks
- Any process that needs to run for hours/days
- Services requiring monitoring and restart capabilities
Architecture
+-------------------------------------------------+
| Service Manager Script |
+-------------------------------------------------+
| start | stop | status | restart |
+-----+-----+----+-----+----+-----+------+-------+
| | | |
v v v v
+----------+ +--------+ +--------+ +--------------+
| PID File | | Kill | | Check | | Stop + Start |
| + nohup | |Process | | PID | | |
+----------+ +--------+ +--------+ +--------------+
|
v
+--------------------------------------+
| Log Files |
| /tmp/service.log /tmp/service.pid |
+--------------------------------------+
Implementation
Basic Service Script
#!/bin/bash
# service.sh - Generic service manager
SERVICE_NAME="myservice"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PID_FILE="/tmp/${SERVICE_NAME}.pid"
LOG_FILE="/tmp/${SERVICE_NAME}.log"
# Command to run (customize this)
*See sub-skills for full details.*
### Multi-Service Manager
```bash
#!/bin/bash
# services.sh - Manage multiple services
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Define services
declare -A SERVICES=(
["extract"]="python3 ${SCRIPT_DIR}/extract.py"
["embed"]="python3 ${SCRIPT_DIR}/embed.py"
*See sub-skills for full details.*
### Status Dashboard Script
```bash
#!/bin/bash
# status.sh - Rich status display
DB_PATH="${1:-./database.db}"
# Colors
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
*See sub-skills for full details.*
### Python Service Wrapper
```python
#!/usr/bin/env python3
"""Python service with graceful shutdown."""
import signal
import sys
import time
import logging
logging.basicConfig(
*See sub-skills for full details.*
## Example Usage
```bash
# Single service
./service.sh start
./service.sh status
./service.sh logs
./service.sh stop
# Multiple services
./services.sh start # Start all
./services.sh start extract # Start specific
./services.sh status # Show all status
./services.sh stop # Stop all
# Status dashboard
./status.sh
Related Skills
- pdf/text-extractor - Long-running extraction job
- semantic-search-setup - Embedding generation service
- knowledge-base-builder - Background indexing
Version History
- 2.0.0 (2026-01-02): Upgraded to v2 template - added Quick Start, Execution Checklist, Error Handling, Metrics sections; enhanced frontmatter with version, category, related_skills
- 1.0.0 (2024-10-15): Initial release with service manager scripts, multi-service support, status dashboard, Python wrapper, graceful shutdown handling
Sub-Skills
- Best Practices
Sub-Skills
- Execution Checklist
- Error Handling
- Metrics
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
gsd-complete-milestone
Archive completed milestone and prepare for next version
gsd-reapply-patches
Reapply local modifications after a GSD update
gsd-verify-work
Validate built features through conversational UAT
gsd-thread
Manage persistent context threads for cross-session work
clinical-trial-protocol
Generate clinical trial protocols for medical devices or drugs through a modular, waypoint-based architecture with research-only and full protocol modes.
single-cell-rna-qc
Performs quality control on single-cell RNA-seq data (.h5ad or .h5 files) using scverse best practices with MAD-based filtering and comprehensive visualizations.
Didn't find tool you were looking for?