Set ./cmd/server/admin.go as entrypoint to server build

This commit is contained in:
ditatompel 2024-05-18 18:42:32 +07:00
parent 0f7029b939
commit 7b6cfee31d
No known key found for this signature in database
GPG key ID: 31D3D06D77950979
5 changed files with 15 additions and 15 deletions

View file

@ -6,6 +6,7 @@ import (
"os"
"strings"
"syscall"
"xmr-remote-nodes/cmd"
"xmr-remote-nodes/internal/database"
"xmr-remote-nodes/internal/repo"
@ -37,6 +38,16 @@ var AdminCmd = &cobra.Command{
},
}
func init() {
cmd.Root.AddCommand(serveCmd)
cmd.Root.AddCommand(importCmd)
cmd.Root.AddCommand(probersCmd)
probersCmd.AddCommand(listProbersCmd)
probersCmd.AddCommand(addProbersCmd)
listProbersCmd.Flags().StringP("sort-by", "s", "last_submit_ts", "Sort by column name, can be id or last_submit_ts")
listProbersCmd.Flags().StringP("sort-dir", "d", "desc", "Sort direction, can be asc or desc")
}
func createAdmin() error {
admin := repo.NewAdminRepo(database.GetDB())
a := repo.Admin{

View file

@ -25,7 +25,7 @@ type importData struct {
DateEntered int `json:"date_entered"`
}
var ImportCmd = &cobra.Command{
var importCmd = &cobra.Command{
Use: "import",
Short: "Import Monero nodes from old API",
Long: `Import Monero nodes from old API.

View file

@ -6,7 +6,6 @@ import (
"strings"
"text/tabwriter"
"time"
"xmr-remote-nodes/cmd"
"xmr-remote-nodes/internal/database"
"xmr-remote-nodes/internal/repo"
@ -15,7 +14,7 @@ import (
var probersCmd = &cobra.Command{
Use: "probers",
Short: "[server] Add, edit, delete, and show registered probers",
Short: "Add, edit, delete, and show registered probers",
Long: `Command to administer prober machines.
This command should only be run on the server which directly connect to the MySQL database.
@ -73,17 +72,9 @@ xmr-nodes probers list -s last_submit_ts -d asc sin1`,
var addProbersCmd = &cobra.Command{
Use: "add [name]",
Short: "[server] Add new prober",
Short: "Add new prober",
Long: `Add new prober machine.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("TODO: Add new prober")
},
}
func init() {
cmd.Root.AddCommand(probersCmd)
probersCmd.AddCommand(listProbersCmd)
probersCmd.AddCommand(addProbersCmd)
listProbersCmd.Flags().StringP("sort-by", "s", "last_submit_ts", "Sort by column name, can be id or last_submit_ts")
listProbersCmd.Flags().StringP("sort-dir", "d", "desc", "Sort direction, can be asc or desc")
}

View file

@ -21,7 +21,7 @@ import (
"github.com/spf13/cobra"
)
var ServeCmd = &cobra.Command{
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Serve the WebUI",
Long: `This command will run HTTP server for APIs and WebUI.`,

View file

@ -9,6 +9,4 @@ import (
func init() {
cmd.Root.AddCommand(server.AdminCmd)
cmd.Root.AddCommand(server.ServeCmd)
cmd.Root.AddCommand(server.ImportCmd)
}