Skip to content

Summaw/GoPhoenix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฅ Phoenix

Live hot-reload runtime for Go applications with zero-downtime restarts.

Go Reference Go Report Card License: MIT

Phoenix brings hot-reload to Go. Save your code, and Phoenix automatically rebuilds and restarts your applicationโ€”on Linux/macOS, it even transfers open TCP connections to the new process so clients never disconnect.

โœจ Features

  • ๐Ÿ”„ Instant Rebuilds โ€” File watcher detects changes and triggers builds automatically
  • ๐Ÿ”Œ Connection Handoff โ€” Open TCP connections transfer to new process (Linux/macOS)
  • ๐Ÿ’พ State Preservation โ€” Serialize sessions, caches, and counters across reloads
  • โšก Incremental Builds โ€” Source hashing skips rebuilds when nothing changed
  • ๐ŸŽจ Beautiful Output โ€” Powered by Aurora for stunning terminal UI
  • ๐Ÿ“ฆ SDK Integration โ€” Drop-in library for full hot-reload support in your apps
  • ๐ŸชŸ Cross-Platform โ€” Works on Windows, Linux, and macOS

๐Ÿš€ Quick Start

Installation

go install github.com/Summaw/GoPhoenix/cmd/phoenix@latest

Usage

phoenix ./cmd/myapp

That's it. Phoenix watches your files, rebuilds on save, and restarts your app.

With the SDK (Full Hot-Reload)

For connection handoff and state preservation, integrate the SDK:

package main

import (
    "net/http"
    "github.com/Summaw/GoPhoenix/pkg/sdk"
)

func main() {
    app := sdk.New(sdk.WithAddress(":8080"))

    mux := http.NewServeMux()
    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello from Phoenix! ๐Ÿ”ฅ"))
    })

    app.ListenAndServe(mux)
}

๐ŸŽฌ Demo

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•—   โ”‚
โ”‚   โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•”โ•   โ”‚
โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ•”โ•    โ”‚
โ”‚   โ–ˆโ–ˆโ•”โ•โ•โ•โ• โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•—    โ”‚
โ”‚   โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•—   โ”‚
โ”‚   โ•šโ•โ•     โ•šโ•โ•  โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•  โ•šโ•โ•โ•โ•โ•šโ•โ•โ•šโ•โ•  โ•šโ•โ•   โ”‚
โ”‚                 Hot Reload Runtime for Go                  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
  12:34:56.789  โ— INFO   Starting Phoenix
                โ”œโ”€ target: ./cmd/server
                โ”œโ”€ watch: .
                โ””โ”€ binary: ./bin/app.exe
  12:34:56.812  โœ“ SUCCESS  Build successful
                โ”œโ”€ binary: ./bin/app.exe
                โ””โ”€ duration: 156ms
  12:34:56.834  โœ“ SUCCESS  Application started
                โ””โ”€ pid: 12345
  12:35:02.123  โ— INFO   Change detected
                โ””โ”€ file: ./handlers/api.go
  12:35:02.456  โœ“ SUCCESS  Build complete
                โ””โ”€ duration: 203ms
  12:35:02.478  โœ“ SUCCESS  Application restarted
                โ””โ”€ pid: 12346

๐Ÿ”ง How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Phoenix Daemon                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                              โ”‚
โ”‚   ๐Ÿ“ Watch Files  โ†’  ๐Ÿ”จ Rebuild  โ†’  ๐Ÿ”„ Handoff              โ”‚
โ”‚                                                              โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚   โ”‚  .go     โ”‚      โ”‚ go build โ”‚      โ”‚  New     โ”‚         โ”‚
โ”‚   โ”‚  files   โ”‚  โ”€โ”€โ–ถ โ”‚          โ”‚  โ”€โ”€โ–ถ โ”‚ Process  โ”‚         โ”‚
โ”‚   โ”‚  change  โ”‚      โ”‚          โ”‚      โ”‚          โ”‚         โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ”‚                                              โ”‚               โ”‚
โ”‚                           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                          โ”‚
โ”‚                    โ”‚ Transfer:   โ”‚                          โ”‚
โ”‚                    โ”‚ โ€ข Listeners โ”‚                          โ”‚
โ”‚                    โ”‚ โ€ข State     โ”‚                          โ”‚
โ”‚                    โ”‚ โ€ข Sessions  โ”‚                          โ”‚
โ”‚                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

On Linux/macOS, Phoenix uses Unix socket file descriptor passing (SCM_RIGHTS) to transfer open TCP listeners between processesโ€”clients stay connected through the reload.

๐Ÿ“‹ CLI Options

phoenix [options] <package>

Options:
  -watch     Paths to watch (comma-separated)     default: "."
  -ext       File extensions to watch             default: ".go"
  -exclude   Paths to exclude                     default: "vendor,node_modules,.git"
  -bin       Output binary path                   default: "./bin/app"
  -drain     Graceful shutdown timeout            default: 30s
  -debug     Enable debug logging                 default: false

Examples:
  phoenix ./cmd/server
  phoenix -watch=./cmd,./internal ./cmd/api
  phoenix -ext=.go,.html -debug .

๐Ÿ’พ State Preservation

Keep data alive across reloads:

type MyCache struct {
    data map[string]string
    mu   sync.RWMutex
}

func (c *MyCache) Snapshot() ([]byte, error) {
    c.mu.RLock()
    defer c.mu.RUnlock()
    return json.Marshal(c.data)
}

func (c *MyCache) Restore(data []byte) error {
    c.mu.Lock()
    defer c.mu.Unlock()
    return json.Unmarshal(data, &c.data)
}

app := sdk.New(
    sdk.WithStateProvider("cache", myCache),
)

๐Ÿ†š Comparison

Feature Phoenix Air Fresh Realize
Hot reload โœ… โŒ โŒ โŒ
Zero downtime โœ… โŒ โŒ โŒ
Connection handoff โœ… โŒ โŒ โŒ
State preservation โœ… โŒ โŒ โŒ
SDK integration โœ… โŒ โŒ โŒ
Cross-platform โœ… โœ… โœ… โœ…
Beautiful UI โœ… โš ๏ธ โŒ โš ๏ธ

๐Ÿ“ Project Structure

phoenix/
โ”œโ”€โ”€ cmd/phoenix/          # CLI daemon
โ”œโ”€โ”€ pkg/sdk/              # Application SDK
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ watcher/          # File system monitoring
โ”‚   โ”œโ”€โ”€ compiler/         # Build orchestration
โ”‚   โ”œโ”€โ”€ handoff/          # Connection & state transfer
โ”‚   โ”œโ”€โ”€ process/          # Process lifecycle
โ”‚   โ””โ”€โ”€ state/            # State serialization
โ””โ”€โ”€ examples/basic/       # Demo application

โš ๏ธ Platform Notes

Platform Connection Handoff State Transfer
Linux โœ… Full support โœ…
macOS โœ… Full support โœ…
Windows โŒ Quick restart โœ…

On Windows, Phoenix performs a fast restart instead of true zero-downtime handoff (Unix sockets required for FD passing).

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.

๐Ÿ™ Credits

  • Terminal UI powered by Aurora
  • Inspired by Erlang's hot code loading

Like Phoenix? Give it a โญ to support the project!

About

๐Ÿ”ฅ Live hot-reload runtime for Go with zero-downtime restarts, connection handoff, and state preservation

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages