2024-09-27 15:02:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
stdlog "log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"golang.org/x/crypto/ssh/terminal"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
|
|
|
2024-11-19 09:31:29 +00:00
|
|
|
backendServer "github.com/status-im/status-go/cmd/status-backend/server"
|
2024-11-06 17:36:49 +00:00
|
|
|
"github.com/status-im/status-go/internal/version"
|
2024-09-27 15:02:18 +00:00
|
|
|
"github.com/status-im/status-go/logutils"
|
2024-11-19 09:31:29 +00:00
|
|
|
mediaServer "github.com/status-im/status-go/server"
|
2024-09-27 15:02:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2024-11-19 09:31:29 +00:00
|
|
|
address = flag.String("address", "", "host:port to listen")
|
|
|
|
useMediaHTTPS = flag.Bool("media-https", true, "use HTTPS for media server (default: true)")
|
|
|
|
logger = log.New("package", "status-go/cmd/status-backend")
|
2024-09-27 15:02:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
logSettings := logutils.LogSettings{
|
|
|
|
Enabled: true,
|
|
|
|
MobileSystem: false,
|
|
|
|
Level: "INFO",
|
|
|
|
}
|
|
|
|
colors := terminal.IsTerminal(int(os.Stdin.Fd()))
|
|
|
|
if err := logutils.OverrideRootLogWithConfig(logSettings, colors); err != nil {
|
|
|
|
stdlog.Fatalf("failed to initialize log: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
2024-11-19 09:31:29 +00:00
|
|
|
mediaServer.UseHTTP = !*useMediaHTTPS
|
|
|
|
|
|
|
|
srv := backendServer.NewServer()
|
2024-09-27 15:02:18 +00:00
|
|
|
srv.Setup()
|
|
|
|
|
|
|
|
err := srv.Listen(*address)
|
|
|
|
if err != nil {
|
|
|
|
logger.Error("failed to start server", "error", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-11-03 00:47:15 +00:00
|
|
|
log.Info("status-backend started",
|
|
|
|
"address", srv.Address(),
|
2024-11-06 17:36:49 +00:00
|
|
|
"version", version.Version(),
|
|
|
|
"gitCommit", version.GitCommit(),
|
2024-11-03 00:47:15 +00:00
|
|
|
)
|
2024-09-27 15:02:18 +00:00
|
|
|
srv.RegisterMobileAPI()
|
|
|
|
srv.Serve()
|
|
|
|
}
|