Skip to content

Commit

Permalink
reload the configuration on SIGHUP
Browse files Browse the repository at this point in the history
  • Loading branch information
tvidal-net authored and muesli committed Feb 13, 2022
1 parent 810ecc9 commit 8bd45e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Description=Deckmaster Service
# adjust the path to deckmaster and .deck file to suit your needs
ExecStart=/usr/local/bin/deckmaster --deck path-to/some.deck
Restart=on-failure
ExecReload=kill -HUP $MAINPID

[Install]
WantedBy=default.target
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func eventLoop(dev *streamdeck.Device, tch chan interface{}) error {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)

hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)

var keyStates sync.Map
keyTimestamps := make(map[uint8]time.Time)

Expand Down Expand Up @@ -144,6 +147,14 @@ func eventLoop(dev *streamdeck.Device, tch chan interface{}) error {
case err := <-shutdown:
return err

case <-hup:
verbosef("Received SIGHUP, reloading configuration...")
deck, err = LoadDeck(dev, "", deck.File)
if err != nil {
return err
}
deck.updateWidgets()

case <-sigs:
fmt.Println("Shutting down...")
return nil
Expand Down

0 comments on commit 8bd45e9

Please sign in to comment.