aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-06 01:37:57 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-06 01:37:57 +0800
commit4ae1a22fecd8b9e1d1e3613edfca0c4e001d4363 (patch)
treeb6cbf7743cbe50614cf12c12e78084a0b544bbb2 /server.go
parentoldgit: Separate some go-git stuff into here (diff)
downloadforge-4ae1a22fecd8b9e1d1e3613edfca0c4e001d4363.tar.gz
forge-4ae1a22fecd8b9e1d1e3613edfca0c4e001d4363.tar.zst
forge-4ae1a22fecd8b9e1d1e3613edfca0c4e001d4363.zip
Ensure server is ready before Run()
Diffstat (limited to 'server.go')
-rw-r--r--server.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/server.go b/server.go
index 8c14e3e..fdedf3c 100644
--- a/server.go
+++ b/server.go
@@ -45,6 +45,8 @@ type Server struct {
templates *template.Template
ircBot *irc.Bot
+
+ ready bool
}
func (s *Server) Setup() {
@@ -63,14 +65,20 @@ func (s *Server) Setup() {
"forge_version": version,
// Some other ones are populated after config parsing
}
-}
-func (s *Server) Run() {
misc.NoneOrPanic(s.loadTemplates())
misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embeddedResourcesFS.Open("git2d/git2d")), s.config.Git.DaemonPath))
misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embeddedResourcesFS.Open("hookc/hookc")), filepath.Join(s.config.Hooks.Execs, "pre-receive")))
misc.NoneOrPanic(os.Chmod(filepath.Join(s.config.Hooks.Execs, "pre-receive"), 0o755))
+ s.ready = true
+}
+
+func (s *Server) Run() error {
+ if !s.ready {
+ return errors.New("not ready")
+ }
+
// Launch Git2D
go func() {
cmd := exec.Command(s.config.Git.DaemonPath, s.config.Git.Socket) //#nosec G204