Skip to main content

Command Palette

Search for a command to run...

Introducing HotPod: Fast Debugging and Process Management for Containers

Updated
Introducing HotPod: Fast Debugging and Process Management for Containers
N

HI there 馃憢

I'm Nir Adler, and I'm a Developer, Hacker and a Maker, you can start with me a conversation on any technical subject out there, you will find me interesting.

Overview

When debugging code inside a container, developers often need to build a new image and deploy a new pod, which can be slow and cumbersome. HotPod eliminates this hassle by allowing developers to copy updated files into a running container and restart the process with the new code鈥攚ithout redeploying the container. This makes debugging and development faster and more efficient.

HotPod is an open-source, lightweight process manager built in Go, designed to dynamically start, stop, and restart processes inside running containers. It provides an easy way to manage processes while keeping the pod alive.

Why HotPod?

HotPod is designed to solve common challenges faced when debugging and managing processes inside containers:

  • Fast Debugging and Development: Modify code in a running container and restart the process instantly without redeploying.

  • Keep-Alive Functionality: Ensures the container stays up by restarting critical processes automatically if they exit unexpectedly.

  • Lightweight and Efficient: Written in Go with minimal resource overhead, making it ideal for cloud-native applications.

  • Graceful Shutdown: Supports SIGTERM handling with fallback to SIGKILL for robust process control.

  • Thread-Safe Execution: Utilizes Go's synchronization mechanisms to prevent multiple instances of the same process from running simultaneously.

Getting Started with HotPod

Installation

Download the latest HotPod release from the GitHub releases page:

wget https://github.com/niradler/hotpod/releases/latest/download/hotpod-linux-amd64 -O hotpod
chmod +x hotpod
./hotpod -help

Running a Process with HotPod

You can use HotPod to run and manage a simple HTTP server inside a container:

./hotpod -command "python -m http.server 8000" -shell "sh" -keepalive=true -host localhost -port 8080

Deploying HotPod in a Container

To demonstrate HotPod in action, let鈥檚 set up a Python-based container that uses HotPod to manage its processes.

Example: Running a Python Server with HotPod

Create a Dockerfile:

FROM python:3.9-alpine
WORKDIR /app

ARG HOTPOD_VERSION=latest

RUN wget https://github.com/niradler/hotpod/releases/latest/download/hotpod-linux-amd64 -O /app/hotpod && \
    chmod +x /app/hotpod

CMD ["./hotpod", "-command", "python ./app.py", "-port", "8080", "-keepalive", "-host", ""]

Running the Container

docker build -t my-python-app .
docker run -d --name my-app-container my-python-app

Hot-Reloading Code Without Restarting the Container

Instead of rebuilding and redeploying an image to apply code changes, use HotPod to dynamically update your running process.

  1. Copy the updated script into the running container:

     docker cp new_app.py my-app-container:/app/new_app.py
    
  2. Use HotPod鈥檚 API to restart the process with the new code:

     curl -X POST http://localhost:8080/start -d '{"command": "python /app/new_app.py", "replace": true}'
    

HotPod ensures the previous process is gracefully stopped before launching the new one, preventing conflicts and ensuring smooth transitions.

Use Cases

HotPod significantly improves debugging and process management in multiple scenarios:

  • Fast Debugging Inside Containers: Update code and restart processes without redeploying the container.

  • Local Development: Hot-reload applications inside containers while preserving state.

  • Microservices in Kubernetes: Manage background jobs within pods without restarting them.

  • CI/CD Pipelines: Execute test suites and manage ephemeral workloads without disrupting container execution.

API & Configuration

HotPod exposes an API for process management, allowing developers to integrate it seamlessly into their workflows.

Full API docs can be found in: https://github.com/niradler/hotpod/blob/master/swagger.yaml

CLI Configuration Options

OptionDescriptionDefault
-commandThe command to run""
-shellThe shell to execute the command (e.g., sh)sh
-keepaliveKeep the process running persistentlyfalse
-hostThe host to listen onlocalhost
-portThe API server port8080

https://github.com/niradler/hotpod

More from this blog

P

Piece by Piece

46 posts

Hi 馃憢, let me share a story with you. I don't want to overwhelm you, so I'm serving this story piece by piece.