github.com/JBoudou/Itero@v0.1.7/pkg/config/signal.go (about)

     1  // Itero - Online iterative vote application
     2  // Copyright (C) 2021 Joseph Boudou
     3  //
     4  // This program is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Affero General Public License as
     6  // published by the Free Software Foundation, either version 3 of the
     7  // License, or (at your option) any later version.
     8  //
     9  // This program is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  // GNU Affero General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Affero General Public License
    15  // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    16  
    17  // +build !windows
    18  
    19  package config
    20  
    21  import (
    22  	"os"
    23  	"os/signal"
    24  	"syscall"
    25  )
    26  
    27  
    28  func init() {
    29  	ch := make(chan os.Signal, 1)
    30  	signal.Notify(ch, syscall.SIGUSR1)
    31  	go refresher(ch)
    32  }
    33  
    34  func refresher(c <-chan os.Signal) {
    35  	for {
    36  		<- c
    37  		readFile()
    38  	}
    39  }