diff --git a/site.go b/site.go index 042afa1..db97987 100644 --- a/site.go +++ b/site.go @@ -134,6 +134,25 @@ func (site *Site) Start() DeployError { return DeployError{} } +// Stop attempts to stop a Lapis server in the given repository. +func (site *Site) Stop() DeployError { + log.Printf("Stopping Lapis server %s...", site.getName()) + + old_cwd, _ := os.Getwd() + defer syscall.Chdir(old_cwd) + syscall.Chdir(configuration.sites_dir + "/" + site.name) + + cmd := exec.Command("lapis", "term") + if err := cmd.Start(); err != nil { + return newDeployError(1, "stopSite", + fmt.Sprintf("Failed to stop Lapis server in '%s'", site.getName()), "") + } + go func() { + cmd.Wait() + }() + return DeployError{} +} + // Restart attempts to restart the Lapis server in the given repository. func (site *Site) Restart() DeployError { log.Printf("Restarting Lapis server in %s...", site.getName())