All Projects → sagikazarmark → fsig

sagikazarmark / fsig

Licence: MIT license
Send signals to a subprocess when files change

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to fsig

Watomatic
Auto reply app helping you move away from less private messengers like WhatsApp and soon Facebook Messenger
Stars: ✭ 83 (+418.75%)
Mutual labels:  signal
Hang
Extremely simple Linux application that hangs until a signal is received.
Stars: ✭ 156 (+875%)
Mutual labels:  signal
Human Signals
Human-friendly process signals
Stars: ✭ 223 (+1293.75%)
Mutual labels:  signal
Windows Kill
Send signal to process by PID in Windows, like POSIX kill
Stars: ✭ 104 (+550%)
Mutual labels:  signal
Nwaves
.NET library for 1D signal processing focused specifically on audio processing
Stars: ✭ 151 (+843.75%)
Mutual labels:  signal
Signals And Systems Lecture
Continuous- and Discrete-Time Signals and Systems - Theory and Computational Examples
Stars: ✭ 166 (+937.5%)
Mutual labels:  signal
Eventpp
Minimal C++ Event Bus
Stars: ✭ 69 (+331.25%)
Mutual labels:  signal
Voice Gender
Gender recognition by voice and speech analysis
Stars: ✭ 248 (+1450%)
Mutual labels:  signal
Stocks
Programs for stock prediction and evaluation
Stars: ✭ 155 (+868.75%)
Mutual labels:  signal
Skui
Skia-based C++ UI framework
Stars: ✭ 218 (+1262.5%)
Mutual labels:  signal
Edsp
A cross-platform DSP library written in C++ 11/14. This library harnesses the power of C++ templates to implement a complete set of DSP algorithms.
Stars: ✭ 116 (+625%)
Mutual labels:  signal
Signals
General purpose modern C++ Signal-Slot providing ease of use, flexibility and extremely high performance aiming to replace traditional interfaces in real-time applications
Stars: ✭ 137 (+756.25%)
Mutual labels:  signal
Pai
Paradox Magellan, Spectra and EVO, with MQTT, Signal, Pushbullet, Pushover and others
Stars: ✭ 185 (+1056.25%)
Mutual labels:  signal
Ooktools
📡 On-off keying tools for your SD-arrrR
Stars: ✭ 102 (+537.5%)
Mutual labels:  signal
Gipher
tinder like app for gifs built with elm and firebase
Stars: ✭ 229 (+1331.25%)
Mutual labels:  signal
Signal Windows
Unofficial Signal Private Messenger for Windows
Stars: ✭ 83 (+418.75%)
Mutual labels:  signal
Libsignal Node
Signal protocol implementation for Node.js
Stars: ✭ 157 (+881.25%)
Mutual labels:  signal
privacy-settings
Guide to privacy settings for most major softwares and services.
Stars: ✭ 97 (+506.25%)
Mutual labels:  signal
Signalkit
SignalKit is a reactive Swift framework with focus on clean and readable API.
Stars: ✭ 245 (+1431.25%)
Mutual labels:  signal
Signalstickers
🖥📱 An unofficial gallery of stickers for Signal, the secure messenger!
Stars: ✭ 210 (+1212.5%)
Mutual labels:  signal

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].