diff --git a/site.go b/site.go index 8df88b5..e6b7f44 100644 --- a/site.go +++ b/site.go @@ -12,24 +12,35 @@ import ( "github.com/gogs/git-module" ) -// startAllSites attempts to start every server in 'sites_dir' -func startAllSites() DeployError { +// getAllSites gets every site installed +func getAllSites() ([]string, DeployError) { sites_dir := configuration.sites_dir files, err := os.ReadDir(sites_dir) + var sites []string if err != nil { - return newDeployError(1, "startAllSites", - fmt.Sprintf("Failed to read sites from '%s'", sites_dir), fmt.Sprint(err)) + return sites, newDeployError(1, "startAllSites", fmt.Sprintf("Failed to read sites from '%s'", sites_dir), fmt.Sprint(err)) } for _, file := range files { if !file.IsDir() { continue } - err := startSite(file.Name()) + sites = append(sites, file.Name()) + } + return sites, DeployError{} +} + +// startAllSites attempts to start every site +func startAllSites() DeployError { + sites, err := getAllSites() + if err.code != 0 { + return err + } + for _, site := range sites { + err := startSite(site) if err.code != 0 { return err } } - return DeployError{} }