package main import ( "net/http" "os/exec" "path/filepath" "sync" "time" ) type Authenticator func(authtoken string, repo *GitRepository) bool type Web struct { GitHost, WebgitHost string CertbotRenewalGap time.Duration certbotDone chan struct{} srv80, srv443 *http.Server mux sync.Mutex } func (web *Web) Spawn(auth Authenticator) { web.spawnHTTP80() web.spawnHTTP443(auth) web.spawnCertbot() } func (web *Web) Kill() { web.killCertbot() web.killHTTP443() web.killHTTP80() } // One could think of adding an information pathway such that gruau imitates // a post-push hook. Real-world testing with this always-run approach, however, // led to no noticeable performance bottleneck. // See also: `.git/hooks/post-update.sample` func MakeWebServicable(repo *GitRepository) error { cmd := exec.Command("/usr/bin/git", "update-server-info") cmd.Env = make([]string, 0) cmd.Dir = filepath.Join(GruauRepositoriesRoot, repo.ID()) return cmd.Run() }