81 lines
2.9 KiB
TOML
81 lines
2.9 KiB
TOML
# .air.toml
|
|
#
|
|
# A configuration file for the 'air' live-reloading tool.
|
|
# This configuration is tailored for a Go project that needs to be run with specific command-line flags
|
|
# and requires graceful handling of system signals like SIGINT and SIGTERM.
|
|
#
|
|
# To use:
|
|
# 1. Install air: `go install github.com/cosmtrek/air@latest`
|
|
# 2. Place this file, renamed to `.air.toml`, in the root of your project.
|
|
# 3. Run `air` from your terminal in the project root.
|
|
|
|
# The root directory of your project to watch for changes.
|
|
# '.' indicates the current directory where air is run.
|
|
root = "."
|
|
|
|
# A temporary directory for air to store its build artifacts.
|
|
# You should add this directory to your .gitignore file.
|
|
tmp_dir = "tmp"
|
|
|
|
[build]
|
|
# Step 1: Build the Go binary and place it in the tmp directory.
|
|
# Step 2: Copy the configuration file into the tmp directory as well.
|
|
# This ensures all runtime assets are in one place.
|
|
cmd = "go build -o ./tmp/main . && cp config.yaml ./tmp/"
|
|
|
|
# The 'full_bin' command gives us complete control over how the app is run.
|
|
# We first change the directory to 'tmp' so that the application's working
|
|
# directory is where the binary and its config file are located.
|
|
# Then, we execute the binary, pointing it to the config file in the same directory.
|
|
full_bin = "cd ./tmp && ./main -config config.yaml"
|
|
|
|
# A list of directories to watch for file changes.
|
|
# Air will recursively watch these directories.
|
|
include_dir = ["."]
|
|
|
|
# A list of file extensions to watch.
|
|
# Air will restart when any of these files change.
|
|
include_ext = ["go", "toml", "yaml", "yml"]
|
|
|
|
# A list of directories to ignore.
|
|
# It's good practice to ignore temporary directories, vendor folders, and git history.
|
|
exclude_dir = ["tmp", "vendor", ".git"]
|
|
|
|
# A list of specific files to ignore.
|
|
exclude_file = []
|
|
|
|
# A list of regular expressions to exclude files or directories.
|
|
exclude_regex = ["_test.go"]
|
|
|
|
# A list of files or directories to watch that are not in the 'include_dir'.
|
|
# Useful for watching template files if they are outside your main source directories.
|
|
include_file = []
|
|
|
|
# This setting is crucial for graceful shutdowns.
|
|
# It stops the running process on a file change before building and restarting.
|
|
# This ensures that your application's shutdown logic is triggered.
|
|
stop_on_error = true
|
|
|
|
# Send SIGINT (Ctrl+C) to the running process before killing it.
|
|
# This is essential for allowing your application to handle the signal and shut down gracefully.
|
|
send_interrupt = true
|
|
|
|
# The delay in milliseconds to wait for the process to shut down gracefully after sending SIGINT.
|
|
# If your app needs more time for cleanup, you can increase this value.
|
|
kill_delay = 500 # ms
|
|
|
|
[log]
|
|
# Show timestamps in the log output.
|
|
time = true
|
|
|
|
[color]
|
|
# Customize colors for different parts of the air output.
|
|
main = "magenta"
|
|
watcher = "cyan"
|
|
build = "yellow"
|
|
runner = "green"
|
|
|
|
[misc]
|
|
# Delete the temporary binary file on exit.
|
|
clean_on_exit = true
|