Add getAllSites() function to sites.go
This commit is contained in:
parent
8c52e842b0
commit
b07e9a78d8
23
site.go
23
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{}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user