add open in browser

This commit is contained in:
YouROK
2021-01-19 13:34:47 +03:00
parent b210178c51
commit 62b28a618f

View File

@@ -8,6 +8,7 @@ import (
"time" "time"
"github.com/alexflint/go-arg" "github.com/alexflint/go-arg"
"github.com/pkg/browser"
"server" "server"
"server/log" "server/log"
"server/settings" "server/settings"
@@ -20,6 +21,7 @@ type args struct {
LogPath string `arg:"-l" help:"log path"` LogPath string `arg:"-l" help:"log path"`
RDB bool `arg:"-r" help:"start in read-only DB mode"` RDB bool `arg:"-r" help:"start in read-only DB mode"`
DontKill bool `arg:"-k" help:"dont kill program on signal"` DontKill bool `arg:"-k" help:"dont kill program on signal"`
UI bool `arg:"-u" help:"run page torrserver in browser"`
} }
func (args) Version() string { func (args) Version() string {
@@ -45,6 +47,13 @@ func main() {
dnsResolve() dnsResolve()
Preconfig(params.DontKill) Preconfig(params.DontKill)
if params.UI {
go func() {
time.Sleep(time.Second)
browser.OpenURL("http://127.0.0.1:" + params.Port)
}()
}
server.Start(params.Port, params.RDB) server.Start(params.Port, params.RDB)
log.TLogln(server.WaitServer()) log.TLogln(server.WaitServer())
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)