1
0
Fork 0

Moving other source code files into prog package. Renaming processes.json to config.json.

This commit is contained in:
Alexander Andreev 2022-01-02 02:56:46 +04:00
parent 82ecb23a62
commit 0c8dc36697
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F
5 changed files with 11 additions and 10 deletions

View File

@ -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:

View File

@ -17,7 +17,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package main
package prog
import (
"encoding/json"

View File

@ -17,7 +17,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package main
package prog
import "errors"

View File

@ -17,7 +17,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package main
package prog
import (
"encoding/xml"

View File

@ -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()