Get support for sagikazarmark/fsig

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

sagikazarmark/fsig

File Signal (fsig)

Build Status Go Report Card GoDoc

Send signals to a child process upon file changes

This project was born because of the need to reload applications upon Kubernetes ConfigMap changes, but it can be used without the containerization stuff as well.

Fsig is heavily inspired by configmap-reload which provides a similar use case for modern application (like Prometheus) run on Kubernetes.

Usage

usage: fsig --watch=WATCH [<flags>] <signal> <cmd> [<args>...]

Send signals to a child process upon file changes

Flags:
      --help             Show context-sensitive help (also try --help-long and --help-man).
  -w, --watch=WATCH ...  Watched directory (at least one)
      --version          Show application version.

Args:
  <signal>  Signal to be sent to the child process
  <cmd>     Child process command
  [<args>]  Child process arguments

Example

$ fsig -w watched/dir HUP -- ./my_program --arg

Installation

Download a precompiled binary for the latest version.

Ubuntu images

RUN apt-get update && apt-get install -y wget

ENV FSIG_VERSION 0.4.0
RUN wget https://github.com/sagikazarmark/fsig/releases/download/v${FSIG_VERSION}/fsig_${FSIG_VERSION}_linux_amd64.tar.gz \
    && tar -C /usr/local/bin -xzvf fsig_${FSIG_VERSION}_linux_amd64.tar.gz fsig \
    && rm fsig_linux_amd64.tar.gz

Alpine images

RUN apk add --no-cache openssl

ENV FSIG_VERSION 0.4.0
RUN wget https://github.com/sagikazarmark/fsig/releases/download/v${FSIG_VERSION}/fsig_${FSIG_VERSION}_linux_amd64.tar.gz \
    && tar -C /usr/local/bin -xzvf fsig_${FSIG_VERSION}_linux_amd64.tar.gz fsig \
    && rm fsig_linux_amd64.tar.gz

Alternatives

fsig might not always fit your use case. The following alternatives provide similar solutions to the problem fsig tries to solve.

Shell script

Pros:

  • very simple
  • has only two dependencies (bash, inotifywait)

Cons:

  • works by putting processes in the background
#!/bin/bash

{
    echo "Starting [APPLICATION]"
    start_application "$@"
} &

pid=$!
watches=${WATCH_PATHS:-"/path/to/watched/file"}

echo "Setting up watches for ${watches[@]}"

{
    inotifywait -e modify,move,create,delete --timefmt '%d/%m/%y %H:%M' -m --format '%T' ${watches[@]} | while read date time; do
        echo "File change detected at ${time} on ${date}"
        kill -s HUP $pid
    done
    
    echo "Watching file changes failed, killing application"
    kill -TERM $pid
} &

wait $pid || exit 1

Install on Alpine

$ apk add bash inotify-tools

Install on Debian

$ apt-get install bash inotify-tools

Entr

entr is a tool similar to inotifywait with the purpose of providing better user experience when used in scripts.

Pros:

  • tiny dependency
  • very simple usage (compared to the script above)

Cons:

  • cannot watch directories without exiting first which makes it impossible to use in a Docker container

License

The MIT License (MIT). Please see License File for more information.

Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2