fix: migrations and port number

This commit is contained in:
Richard Ramos 2024-05-21 08:02:54 -04:00
parent c579a272d0
commit 4aa52a26b2
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
5 changed files with 28 additions and 2 deletions

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"database/sql" "database/sql"
"errors" "errors"
"fmt"
"net"
"sync" "sync"
"time" "time"
@ -85,9 +87,15 @@ func Execute(ctx context.Context, options Options) error {
return errors.New("no storenodes specified") 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( wakuNode, err := node.New(
node.WithNTP(), node.WithNTP(),
node.WithClusterID(uint16(options.ClusterID)), node.WithClusterID(uint16(options.ClusterID)),
node.WithHostAddress(hostAddr),
) )
if err != nil { if err != nil {
return err return err

View File

@ -10,6 +10,22 @@ import (
) )
var cliFlags = []cli.Flag{ 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)"}, &cli.StringFlag{Name: "config-file", Usage: "loads configuration from a TOML file (cmd-line parameters take precedence)"},
cliutils.NewGenericFlagMultiValue(&cli.GenericFlag{ cliutils.NewGenericFlagMultiValue(&cli.GenericFlag{
Name: "storenode", Name: "storenode",

View File

@ -8,6 +8,8 @@ import (
) )
type Options struct { type Options struct {
Port int
Address string
LogLevel string LogLevel string
LogEncoding string LogEncoding string
LogOutput string LogOutput string

View File

@ -23,7 +23,7 @@ func NewDB(dburl string, logger *zap.Logger) (*sql.DB, error) {
func migrationDriver(db *sql.DB) (database.Driver, error) { func migrationDriver(db *sql.DB) (database.Driver, error) {
return pgx.WithInstance(db, &pgx.Config{ return pgx.WithInstance(db, &pgx.Config{
MigrationsTable: pgx.DefaultMigrationsTable, MigrationsTable: "message_counter_" + pgx.DefaultMigrationsTable,
}) })
} }

View File

@ -43,7 +43,7 @@ func NewDB(dburl string, logger *zap.Logger) (*sql.DB, error) {
func migrationDriver(db *sql.DB) (database.Driver, error) { func migrationDriver(db *sql.DB) (database.Driver, error) {
return sqlite3.WithInstance(db, &sqlite3.Config{ return sqlite3.WithInstance(db, &sqlite3.Config{
MigrationsTable: sqlite3.DefaultMigrationsTable, MigrationsTable: "message_counter_" + sqlite3.DefaultMigrationsTable,
}) })
} }