mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-02 07:41:51 +00:00
cmd/ursrv: Merge ursrv and uraggregate as subcommands
This commit is contained in:
parent
c55b205a0b
commit
6aecc2622c
8
build.go
8
build.go
@ -214,11 +214,17 @@ var targets = map[string]target{
|
|||||||
binaryName: "stupgrades",
|
binaryName: "stupgrades",
|
||||||
},
|
},
|
||||||
"stcrashreceiver": {
|
"stcrashreceiver": {
|
||||||
name: "stupgrastcrashreceiverdes",
|
name: "stcrashreceiver",
|
||||||
description: "Syncthing Crash Server",
|
description: "Syncthing Crash Server",
|
||||||
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/stcrashreceiver"},
|
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/stcrashreceiver"},
|
||||||
binaryName: "stcrashreceiver",
|
binaryName: "stcrashreceiver",
|
||||||
},
|
},
|
||||||
|
"ursrv": {
|
||||||
|
name: "ursrv",
|
||||||
|
description: "Syncthing Usage Reporting Server",
|
||||||
|
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/ursrv"},
|
||||||
|
binaryName: "ursrv",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func initTargets() {
|
func initTargets() {
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
package main
|
package aggregate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -15,26 +16,21 @@ import (
|
|||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dbConn = getEnvDefault("UR_DB_URL", "postgres://user:password@localhost/ur?sslmode=disable")
|
type CLI struct {
|
||||||
|
DBConn string `env:"UR_DB_URL" default:"postgres://user:password@localhost/ur?sslmode=disable"`
|
||||||
func getEnvDefault(key, def string) string {
|
|
||||||
if val := os.Getenv(key); val != "" {
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
return def
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func (cli *CLI) Run() error {
|
||||||
log.SetFlags(log.Ltime | log.Ldate)
|
log.SetFlags(log.Ltime | log.Ldate)
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
|
|
||||||
db, err := sql.Open("postgres", dbConn)
|
db, err := sql.Open("postgres", cli.DBConn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("database:", err)
|
return fmt.Errorf("database: %w", err)
|
||||||
}
|
}
|
||||||
err = setupDB(db)
|
err = setupDB(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("database:", err)
|
return fmt.Errorf("database: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
1169
cmd/ursrv/main.go
1169
cmd/ursrv/main.go
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
package main
|
package serve
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
@ -4,7 +4,7 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
package main
|
package serve
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
package main
|
package serve
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
1167
cmd/ursrv/serve/serve.go
Normal file
1167
cmd/ursrv/serve/serve.go
Normal file
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Loading…
x
Reference in New Issue
Block a user