Moving other source code files into prog package. Renaming processes.json to config.json.
This commit is contained in:
parent
82ecb23a62
commit
0c8dc36697
9
main.go
9
main.go
@ -22,6 +22,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
. "httpprocwatchd/prog"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -56,8 +57,8 @@ func main() {
|
||||
|
||||
log.SetFlags(0)
|
||||
|
||||
flag.StringVar(&oConfigPath, "config", "processes.json", "path to configuration file")
|
||||
flag.StringVar(&oConfigPath, "c", "processes.json", "path to configuration file (shorthand)")
|
||||
flag.StringVar(&oConfigPath, "config", "config.json", "path to configuration file")
|
||||
flag.StringVar(&oConfigPath, "c", "config.json", "path to configuration file (shorthand)")
|
||||
flag.BoolVar(&oShowVersion, "version", false, "show version")
|
||||
flag.BoolVar(&oShowVersion, "v", false, "show version (shorthand)")
|
||||
|
||||
@ -124,7 +125,7 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
srv := createAndStartHTTPServer(conf)
|
||||
srv := CreateAndStartHTTPServer(conf)
|
||||
|
||||
syssignal := make(chan os.Signal, 1)
|
||||
signal.Notify(syssignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||
@ -137,7 +138,7 @@ func main() {
|
||||
fallthrough
|
||||
case syscall.SIGINT | syscall.SIGTERM:
|
||||
log.Println("Shutting down... ")
|
||||
shutdownHTTPServer(srv)
|
||||
ShutdownHTTPServer(srv)
|
||||
log.Println("Server shutted down.")
|
||||
os.Exit(0)
|
||||
case syscall.SIGHUP:
|
||||
|
@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
package prog
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
package prog
|
||||
|
||||
import "errors"
|
||||
|
@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
package prog
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
@ -17,7 +17,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
package prog
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -28,7 +28,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func createAndStartHTTPServer(conf *Configuration) *http.Server {
|
||||
func CreateAndStartHTTPServer(conf *Configuration) *http.Server {
|
||||
router := http.NewServeMux()
|
||||
router.HandleFunc("/processes", AreProcessesUp(&conf.Processes))
|
||||
|
||||
@ -49,7 +49,7 @@ func createAndStartHTTPServer(conf *Configuration) *http.Server {
|
||||
return srv
|
||||
}
|
||||
|
||||
func shutdownHTTPServer(srv *http.Server) {
|
||||
func ShutdownHTTPServer(srv *http.Server) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
Loading…
Reference in New Issue
Block a user