Compare commits
2 Commits
ba71b42369
...
852874a12a
Author | SHA1 | Date | |
---|---|---|---|
852874a12a | |||
09ed6cc8c4 |
19
matrix.go
19
matrix.go
@ -150,6 +150,25 @@ func initMatrix() {
|
|||||||
return text + "\n🟢 Successfully restarted site."
|
return text + "\n🟢 Successfully restarted site."
|
||||||
})
|
})
|
||||||
|
|
||||||
|
registerChatCommand("stop", "Stop a site.", func(ctx context.Context, evt *event.Event, args []string) string {
|
||||||
|
if len(args) < 2 {
|
||||||
|
return "🔴 Invalid site."
|
||||||
|
}
|
||||||
|
site, found, err := getSite(args[1])
|
||||||
|
if err != nil {
|
||||||
|
return "🔴 Failed to get site " + args[2] + "!"
|
||||||
|
} else if !found {
|
||||||
|
return "🔴 Invalid site."
|
||||||
|
}
|
||||||
|
text := "⚪️ Stopping server..."
|
||||||
|
if derr := site.Stop(); derr.code != 0 {
|
||||||
|
derr.SendOverMatrix()
|
||||||
|
return text + "\n🔴 Failed to stop site!"
|
||||||
|
}
|
||||||
|
return text + "\n🟢 Successfully stopped site."
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for range time.Tick(time.Second * 6) {
|
for range time.Tick(time.Second * 6) {
|
||||||
log.Printf("Scanning for queued messages...")
|
log.Printf("Scanning for queued messages...")
|
||||||
|
19
site.go
19
site.go
@ -134,6 +134,25 @@ func (site *Site) Start() DeployError {
|
|||||||
return 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.
|
// Restart attempts to restart the Lapis server in the given repository.
|
||||||
func (site *Site) Restart() DeployError {
|
func (site *Site) Restart() DeployError {
|
||||||
log.Printf("Restarting Lapis server in %s...", site.getName())
|
log.Printf("Restarting Lapis server in %s...", site.getName())
|
||||||
|
Loading…
Reference in New Issue
Block a user