Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Galus - Live Reloading for Go Applications

English | Bahasa Indonesia

Galus is a live reloading tool for Go applications, similar to Air or CompileDaemon. It monitors file changes in your project, automatically recompiles, and restarts the application.

Features

  • Live Reloading: Automatically detects changes in specified file types (e.g., .go) and recompiles and restarts the application.

  • Configurable via .galus.toml: Customize watched directories, file extensions, build commands, and runtime arguments using a TOML configuration file.

  • Colorful CLI Output: Provides clear, color-coded output for better user experience (e.g., green for success, red for errors).

  • Rich CLI Commands: Supports init to create a default configuration file, version to display the app version, and help for command usage details.

  • Graceful Shutdown: Uses SIGTERM to safely stop running processes, with a fallback to force termination if needed. The grace period is configurable via kill_grace.

  • Resilient Reloads: A failed build never kills the currently running binary — the last working version keeps serving until a build succeeds.

  • Debounced File Events: Bursts of file changes (e.g. saving many files at once) are combined into a single rebuild via a configurable debounce window, instead of rebuilding once per event.

  • Full File Event Coverage: Responds to file create, write, remove, and rename events, not just writes.

  • Hooks (pre_cmd / post_cmd): Run commands before building (e.g. go vet, go generate) and after the app restarts. A failing pre_cmd aborts the rebuild and keeps the current process running.

  • Environment Variables: Inject env vars into both the build command and the running process via the env config option.

  • Polling Fallback: When polling = true, Galus periodically scans the project for changes instead of relying solely on filesystem events — useful for editors or Docker bind-mounts that don't emit fsnotify events reliably.

  • Configuration Validation: Ensures build_cmd and command_args are valid before starting the live reload process.

  • Cross-Platform: Works on any platform supported by Go, with easy installation via go get.

Installation

  1. Install galus using go get:

    go get github.com/aliftech/galus
  2. Install the binary to make galus available globally:

    go install github.com/aliftech/galus
  3. Ensure $GOPATH/bin is in your $PATH:

    export PATH=$PATH:$(go env GOPATH)/bin

Usage

  1. Initialize a configuration file: In your project directory, run:

    galus init

    This creates a .galus.toml configuration file with default setting.

  2. Start live reloading: In your project directory, run:

    galus

    Galus will monitor file changes (e.g., .go files), recompile, and restart your application.

Configuration

The .galus.toml file allows you to customize Galus behavior. Example configuration:

root_dir = "."
tmp_dir = "tmp"
include_ext = ["go"]
exclude_dir = [".git", "vendor", "tmp"]
build_cmd = "go build -o ./tmp/main ."
binary_name = "tmp/main"
command_args = ["tmp/main"]
kill_grace = "5s"
debounce = "300ms"
pre_cmd = []
post_cmd = []
env = {}
polling = false
polling_interval = "500ms"
  • root_dir: Directory to monitor for changes.
  • tmp_dir: Temporary directory for compiled binaries.
  • include_ext: File extensions to monitor (e.g., ["go", "html"]).
  • exclude_dir: Directories to ignore.
  • build_cmd: Command to compile the application.
  • binary_name: Name of the compiled binary.
  • command_args: Arguments to run the binary.
  • kill_grace: How long to wait for the running process to stop gracefully (via SIGTERM) before force-killing it.
  • debounce: How long to wait after the last file change before rebuilding, combining bursts of events into a single rebuild.
  • pre_cmd: Commands to run before each build (e.g. ["go vet ./...", "go generate ./..."]). If any fails, the rebuild is aborted and the current process keeps running.
  • post_cmd: Commands to run after the app restarts (e.g. ["go run ./cmd/gen"]). Failures are logged but do not stop the app.
  • env: Environment variables applied to both the build and the running process (e.g. { PORT = "8080", DEBUG = "true" }).
  • polling: Set to true to scan the project periodically instead of relying solely on filesystem events.
  • polling_interval: How often to scan for changes when polling is enabled.

About

Galus is a live reloading tool for Go applications, similar to Air or CompileDaemon.

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages