Make sentry support play wav file when build success/failed, Can anyone help on try it on macOS?

Usage:

  1. clone code from GitHub - zw963/sentry: Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes
  2. shards build --release
  3. Add ./bin or copy ./bin/sentry into PATH.
  4. you have to keep source folder leave there, because sentry need find wav files from there.

Sentry allows customization of the build and run commands, it doesn’t have to do it by default. I use a script to run sentry:

run_sentry () {
  ./sentry -w 'src/**/*.cr' -w 'views/**/*.ecr' -b "time shards build -s --error-trace $1" -r "bin/$1"
}

Then I run run_sentry $APP where $APP is an key in the targets object in the project’s shard.yml. You can add your sound player after the build command.

2 Likes

Hi, @jgaskins , i use this same hack make play sound works even when start crystal app use sentry in the docker-compose

following is solution:

1. start sentry in Dockerfile like this:

CMD sentry -b 'shards build && touch tmp/.success || (touch tmp/.error; exit 1)' -r 'bin/app'

2. write a bash script use inotifywait for monitor the file touched in my local laptop, like this: (i write it in the .rvmrc, which will run automatically when i entering my project

if which inotifywait &>/dev/null && ! pgrep inotifywait &>/dev/null; then
    touch tmp/.success tmp/.error

    (
        while inotifywait -qq -e attrib tmp/.success
        do
            aplay ~/Crystal/git/sentry/src/sounds/success.wav 2>/dev/null
        done
    )&

    (
        while inotifywait -qq -e attrib tmp/.error
        do
            aplay ~/Crystal/git/sentry/src/sounds/error.wav 2>/dev/null
        done
    )&
fi

Thanks a lot.


You can install inotifywait use pacman -S inotify-tools in Arch.

3 Likes