mirror of
https://github.com/logos-messaging/storenode-messages-counter.git
synced 2026-01-03 06:33:05 +00:00
fix: migrations and port number
This commit is contained in:
parent
c579a272d0
commit
4aa52a26b2
@ -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
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -8,6 +8,8 @@ import (
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Port int
|
||||
Address string
|
||||
LogLevel string
|
||||
LogEncoding string
|
||||
LogOutput string
|
||||
|
||||
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user