Adding autostart from database
This commit is contained in:
parent
07c11d360d
commit
b42701e4ef
@ -3,8 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"regexp"
|
"context"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -82,6 +83,28 @@ func main() {
|
|||||||
re = regexp.MustCompile("^https?://([^/]*)/(.*)$")
|
re = regexp.MustCompile("^https?://([^/]*)/(.*)$")
|
||||||
matchurl = regexp.MustCompile("http?s://[\\w\\-]+\\.[\\w\\-]+\\S*")
|
matchurl = regexp.MustCompile("http?s://[\\w\\-]+\\.[\\w\\-]+\\S*")
|
||||||
|
|
||||||
|
// Start instances located in database
|
||||||
|
rows, err := pool.Query(context.Background(), "SELECT endpoint FROM instances")
|
||||||
|
if err != nil {
|
||||||
|
logErr("Unable to select from instances")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
var endpoint string
|
||||||
|
err = rows.Scan(&endpoint)
|
||||||
|
if err != nil {
|
||||||
|
logErr("Unable to iterate")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, exists := GetRunner(endpoint)
|
||||||
|
if exists == false {
|
||||||
|
go StartInstance(endpoint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start from Autostart list
|
||||||
for _, endpoint := range settings.Autostart {
|
for _, endpoint := range settings.Autostart {
|
||||||
logInfo("Autostarting " + endpoint)
|
logInfo("Autostarting " + endpoint)
|
||||||
_, exists := GetRunner(endpoint)
|
_, exists := GetRunner(endpoint)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user