diff --git a/cmd/storemsgcounter/execute.go b/cmd/storemsgcounter/execute.go index 6e8b979..7436fb4 100644 --- a/cmd/storemsgcounter/execute.go +++ b/cmd/storemsgcounter/execute.go @@ -4,6 +4,8 @@ import ( "context" "database/sql" "errors" + "fmt" + "net" "sync" "time" @@ -85,9 +87,15 @@ func Execute(ctx context.Context, options Options) error { return errors.New("no storenodes specified") } + hostAddr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", options.Address, options.Port)) + if err != nil { + return err + } + wakuNode, err := node.New( node.WithNTP(), node.WithClusterID(uint16(options.ClusterID)), + node.WithHostAddress(hostAddr), ) if err != nil { return err diff --git a/cmd/storemsgcounter/flags.go b/cmd/storemsgcounter/flags.go index 5ab8f60..dfeb663 100644 --- a/cmd/storemsgcounter/flags.go +++ b/cmd/storemsgcounter/flags.go @@ -10,6 +10,22 @@ import ( ) var cliFlags = []cli.Flag{ + altsrc.NewIntFlag(&cli.IntFlag{ + Name: "tcp-port", + Aliases: []string{"port", "p"}, + Value: 0, + Usage: "Libp2p TCP listening port (0 for random)", + Destination: &options.Port, + EnvVars: []string{"STORE_MSG_CTR_TCP_PORT"}, + }), + altsrc.NewStringFlag(&cli.StringFlag{ + Name: "address", + Aliases: []string{"host", "listen-address"}, + Value: "0.0.0.0", + Usage: "Listening address", + Destination: &options.Address, + EnvVars: []string{"STORE_MSG_CTR_ADDRESS"}, + }), &cli.StringFlag{Name: "config-file", Usage: "loads configuration from a TOML file (cmd-line parameters take precedence)"}, cliutils.NewGenericFlagMultiValue(&cli.GenericFlag{ Name: "storenode", diff --git a/cmd/storemsgcounter/options.go b/cmd/storemsgcounter/options.go index e71d899..25e0555 100644 --- a/cmd/storemsgcounter/options.go +++ b/cmd/storemsgcounter/options.go @@ -8,6 +8,8 @@ import ( ) type Options struct { + Port int + Address string LogLevel string LogEncoding string LogOutput string diff --git a/internal/persistence/postgres/postgres.go b/internal/persistence/postgres/postgres.go index ab484dd..765803a 100644 --- a/internal/persistence/postgres/postgres.go +++ b/internal/persistence/postgres/postgres.go @@ -23,7 +23,7 @@ func NewDB(dburl string, logger *zap.Logger) (*sql.DB, error) { func migrationDriver(db *sql.DB) (database.Driver, error) { return pgx.WithInstance(db, &pgx.Config{ - MigrationsTable: pgx.DefaultMigrationsTable, + MigrationsTable: "message_counter_" + pgx.DefaultMigrationsTable, }) } diff --git a/internal/persistence/sqlite/sqlite.go b/internal/persistence/sqlite/sqlite.go index d2a6da9..cc797d4 100644 --- a/internal/persistence/sqlite/sqlite.go +++ b/internal/persistence/sqlite/sqlite.go @@ -43,7 +43,7 @@ func NewDB(dburl string, logger *zap.Logger) (*sql.DB, error) { func migrationDriver(db *sql.DB) (database.Driver, error) { return sqlite3.WithInstance(db, &sqlite3.Config{ - MigrationsTable: sqlite3.DefaultMigrationsTable, + MigrationsTable: "message_counter_" + sqlite3.DefaultMigrationsTable, }) }