Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add all below settings to configuration #118

Open
github-actions bot opened this issue Feb 17, 2025 · 0 comments
Open

add all below settings to configuration #118

github-actions bot opened this issue Feb 17, 2025 · 0 comments
Assignees
Labels

Comments

@github-actions
Copy link
Contributor

// TODO add all below settings to configuration

package server

import (
	"net/http"
	"time"

	"github.com/gogrlx/grlx/api"
	"github.com/gogrlx/grlx/config"
	"github.com/gogrlx/grlx/types"
	"github.com/taigrr/log-socket/log"
)

var version types.Version

func SetVersion(v types.Version) {
	version = v
}

func StartAPIServer() *http.Server {
	CertFile := config.CertFile
	FarmerInterface := config.FarmerInterface
	FarmerAPIPort := config.FarmerAPIPort
	KeyFile := config.KeyFile
	r := api.NewRouter(version, CertFile)
	srv := http.Server{
		// TODO add all below settings to configuration
		Addr:         FarmerInterface + ":" + FarmerAPIPort,
		WriteTimeout: time.Second * 120,
		ReadTimeout:  time.Second * 120,
		IdleTimeout:  time.Second * 120,
		Handler:      r,
	}
	go func() {
		if err := srv.ListenAndServeTLS(CertFile, KeyFile); err != nil {
			if err == http.ErrServerClosed {
				log.Debugf("API Server Shutting down, standby...")
				return
			}
			log.Panicf("API Server failure: %v", err)
		}
	}()

	log.Tracef("API Server started on %s\n", FarmerInterface+":"+FarmerAPIPort)
	return &srv
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant