UDP buffer configuration in fly (#660)
Co-authored-by: walker-16 <agpazos85@gmail.com>
This commit is contained in:
parent
bf02b2054b
commit
503a9da5d3
|
@ -1,7 +1,8 @@
|
|||
ENVIRONMENT=production-mainnet
|
||||
NAMESPACE=wormscan
|
||||
NAME=wormscan-fly
|
||||
REPLICAS=5
|
||||
API_PORT=8000
|
||||
REPLICAS=3
|
||||
IMAGE_NAME=
|
||||
RESOURCES_LIMITS_MEMORY=512Mi
|
||||
RESOURCES_LIMITS_CPU=700m
|
||||
|
@ -10,6 +11,7 @@ RESOURCES_REQUESTS_CPU=500m
|
|||
SQS_URL=
|
||||
SQS_AWS_REGION=
|
||||
P2P_NETWORK=mainnet
|
||||
P2P_PORT=8999
|
||||
PPROF_ENABLED=false
|
||||
MAX_HEALTH_TIME_SECONDS=90
|
||||
AWS_IAM_ROLE=
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
ENVIRONMENT=production-testnet
|
||||
NAMESPACE=wormscan-testnet
|
||||
NAME=wormscan-fly
|
||||
API_PORT=8000
|
||||
REPLICAS=3
|
||||
IMAGE_NAME=
|
||||
RESOURCES_LIMITS_MEMORY=256Mi
|
||||
|
@ -10,6 +11,7 @@ RESOURCES_REQUESTS_CPU=250m
|
|||
SQS_URL=
|
||||
SQS_AWS_REGION=
|
||||
P2P_NETWORK=testnet
|
||||
P2P_PORT=8999
|
||||
PPROF_ENABLED=false
|
||||
MAX_HEALTH_TIME_SECONDS=300
|
||||
AWS_IAM_ROLE=
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
ENVIRONMENT=staging-mainnet
|
||||
NAMESPACE=wormscan
|
||||
NAME=wormscan-fly
|
||||
API_PORT=8000
|
||||
REPLICAS=3
|
||||
IMAGE_NAME=
|
||||
RESOURCES_LIMITS_MEMORY=512Mi
|
||||
|
@ -10,6 +11,7 @@ RESOURCES_REQUESTS_CPU=500m
|
|||
SQS_URL=
|
||||
SQS_AWS_REGION=
|
||||
P2P_NETWORK=mainnet
|
||||
P2P_PORT=8999
|
||||
PPROF_ENABLED=true
|
||||
MAX_HEALTH_TIME_SECONDS=90
|
||||
AWS_IAM_ROLE=
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
ENVIRONMENT=staging-testnet
|
||||
NAMESPACE=wormscan-testnet
|
||||
NAME=wormscan-fly
|
||||
API_PORT=8001
|
||||
REPLICAS=2
|
||||
IMAGE_NAME=
|
||||
RESOURCES_LIMITS_MEMORY=256Mi
|
||||
|
@ -10,6 +11,7 @@ RESOURCES_REQUESTS_CPU=250m
|
|||
SQS_URL=
|
||||
SQS_AWS_REGION=
|
||||
P2P_NETWORK=testnet
|
||||
P2P_PORT=8998
|
||||
PPROF_ENABLED=false
|
||||
MAX_HEALTH_TIME_SECONDS=300
|
||||
AWS_IAM_ROLE=
|
||||
|
|
|
@ -14,15 +14,24 @@ spec:
|
|||
app: {{ .NAME }}
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/port: "8000"
|
||||
prometheus.io/port: "{{ .API_PORT }}"
|
||||
spec:
|
||||
hostNetwork: true
|
||||
restartPolicy: Always
|
||||
terminationGracePeriodSeconds: 40
|
||||
serviceAccountName: fly
|
||||
initContainers:
|
||||
- name: init-fly
|
||||
image: busybox:1.28
|
||||
command: [ "sh", "-c", "sysctl -w net.core.rmem_max=2500000" ]
|
||||
securityContext:
|
||||
privileged: true
|
||||
containers:
|
||||
- name: {{ .NAME }}
|
||||
image: {{ .IMAGE_NAME }}
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
readinessProbe:
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 20
|
||||
|
@ -30,7 +39,7 @@ spec:
|
|||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /api/ready
|
||||
port: 8000
|
||||
port: {{ .API_PORT }}
|
||||
livenessProbe:
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
|
@ -38,12 +47,12 @@ spec:
|
|||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: 8000
|
||||
port: {{ .API_PORT }}
|
||||
env:
|
||||
- name: ENVIRONMENT
|
||||
value: {{ .ENVIRONMENT }}
|
||||
- name: API_PORT
|
||||
value: "8000"
|
||||
value: "{{ .API_PORT }}"
|
||||
- name: MONGODB_URI
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
@ -56,6 +65,8 @@ spec:
|
|||
key: mongo-database
|
||||
- name: P2P_NETWORK
|
||||
value: {{ .P2P_NETWORK }}
|
||||
- name: P2P_PORT
|
||||
value: "{{ .P2P_PORT }}"
|
||||
- name: PPROF_ENABLED
|
||||
value: "{{ .PPROF_ENABLED }}"
|
||||
- name: SQS_URL
|
||||
|
@ -99,4 +110,15 @@ spec:
|
|||
cpu: {{ .RESOURCES_LIMITS_CPU }}
|
||||
requests:
|
||||
memory: {{ .RESOURCES_REQUESTS_MEMORY }}
|
||||
cpu: {{ .RESOURCES_REQUESTS_CPU }}
|
||||
cpu: {{ .RESOURCES_REQUESTS_CPU }}
|
||||
tolerations:
|
||||
- key: "dedicated"
|
||||
operator: "Equal"
|
||||
value: "wormholescan"
|
||||
effect: "NoSchedule"
|
||||
- key: "dedicated"
|
||||
operator: "Equal"
|
||||
value: "wormholescan"
|
||||
effect: "NoExecute"
|
||||
nodeSelector:
|
||||
eks.amazonaws.com/nodegroup-selector: "wormholescan"
|
||||
|
|
|
@ -37,7 +37,6 @@ type P2pNetworkConfig struct {
|
|||
Enviroment string
|
||||
P2pNetworkID string
|
||||
P2pBootstrap string
|
||||
P2pPort uint
|
||||
}
|
||||
|
||||
// GetP2pNetwork get p2p network config.
|
||||
|
@ -47,11 +46,11 @@ func GetP2pNetwork() (*P2pNetworkConfig, error) {
|
|||
|
||||
switch p2pEnviroment {
|
||||
case domain.P2pMainNet:
|
||||
return &P2pNetworkConfig{domain.P2pMainNet, MainNetP2ppNetworkID, MainNetP2pBootstrap, MainNetP2pPort}, nil
|
||||
return &P2pNetworkConfig{domain.P2pMainNet, MainNetP2ppNetworkID, MainNetP2pBootstrap}, nil
|
||||
case domain.P2pTestNet:
|
||||
return &P2pNetworkConfig{domain.P2pTestNet, TestNetP2ppNetworkID, TestNetP2pBootstrap, TestNetP2pPort}, nil
|
||||
return &P2pNetworkConfig{domain.P2pTestNet, TestNetP2ppNetworkID, TestNetP2pBootstrap}, nil
|
||||
case domain.P2pDevNet:
|
||||
return &P2pNetworkConfig{domain.P2pDevNet, DevNetP2ppNetworkID, DevNetP2pBootstrap, DevNetP2pPort}, nil
|
||||
return &P2pNetworkConfig{domain.P2pDevNet, DevNetP2ppNetworkID, DevNetP2pBootstrap}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf(`invalid P2P_NETWORK enviroment variable: "%s"`, p2pEnviroment)
|
||||
}
|
||||
|
@ -124,11 +123,13 @@ func GetPrefix() string {
|
|||
}
|
||||
|
||||
type Configuration struct {
|
||||
ObservationsChannelSize int `env:"OBSERVATIONS_CHANNEL_SIZE,required"`
|
||||
VaasChannelSize int `env:"VAAS_CHANNEL_SIZE,required"`
|
||||
HeartbeatsChannelSize int `env:"HEARTBEATS_CHANNEL_SIZE,required"`
|
||||
GovernorConfigChannelSize int `env:"GOVERNOR_CONFIG_CHANNEL_SIZE,required"`
|
||||
GovernorStatusChannelSize int `env:"GOVERNOR_STATUS_CHANNEL_SIZE,required"`
|
||||
ObservationsChannelSize int `env:"OBSERVATIONS_CHANNEL_SIZE,required"`
|
||||
VaasChannelSize int `env:"VAAS_CHANNEL_SIZE,required"`
|
||||
HeartbeatsChannelSize int `env:"HEARTBEATS_CHANNEL_SIZE,required"`
|
||||
GovernorConfigChannelSize int `env:"GOVERNOR_CONFIG_CHANNEL_SIZE,required"`
|
||||
GovernorStatusChannelSize int `env:"GOVERNOR_STATUS_CHANNEL_SIZE,required"`
|
||||
ApiPort uint `env:"API_PORT,required"`
|
||||
P2pPort uint `env:"P2P_PORT,required"`
|
||||
}
|
||||
|
||||
// New creates a configuration with the values from .env file and environment variables.
|
||||
|
|
|
@ -386,7 +386,7 @@ func main() {
|
|||
|
||||
// start fly http server.
|
||||
pprofEnabled := config.GetPprofEnabled()
|
||||
server := server.NewServer(guardianCheck, logger, repository, sqsConsumer, *isLocal, pprofEnabled, alertClient)
|
||||
server := server.NewServer(cfg.ApiPort, guardianCheck, logger, repository, sqsConsumer, *isLocal, pprofEnabled, alertClient)
|
||||
server.Start()
|
||||
|
||||
go func() {
|
||||
|
@ -494,8 +494,10 @@ func main() {
|
|||
|
||||
// Run supervisor.
|
||||
supervisor.New(rootCtx, logger, func(ctx context.Context) error {
|
||||
components := p2p.DefaultComponents()
|
||||
components.Port = cfg.P2pPort
|
||||
if err := supervisor.Run(ctx, "p2p",
|
||||
p2p.Run(obsvC, obsvReqC, nil, sendC, signedInC, priv, nil, gst, p2pNetworkConfig.P2pNetworkID, p2pNetworkConfig.P2pBootstrap, "", false, rootCtxCancel, nil, nil, govConfigC, govStatusC, nil)); err != nil {
|
||||
p2p.Run(obsvC, obsvReqC, nil, sendC, signedInC, priv, nil, gst, p2pNetworkConfig.P2pNetworkID, p2pNetworkConfig.P2pBootstrap, "", false, rootCtxCancel, nil, nil, govConfigC, govStatusC, components)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
|
||||
"github.com/ansrivas/fiberprometheus/v2"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
@ -19,11 +19,7 @@ type Server struct {
|
|||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewServer(guardianCheck *health.GuardianCheck, logger *zap.Logger, repository *storage.Repository, consumer *sqs.Consumer, isLocal, pprofEnabled bool, alertClient alert.AlertClient) *Server {
|
||||
port := os.Getenv("API_PORT")
|
||||
if port == "" {
|
||||
logger.Fatal("You must set your 'API_PORT' environmental variable")
|
||||
}
|
||||
func NewServer(port uint, guardianCheck *health.GuardianCheck, logger *zap.Logger, repository *storage.Repository, consumer *sqs.Consumer, isLocal, pprofEnabled bool, alertClient alert.AlertClient) *Server {
|
||||
ctrl := NewController(guardianCheck, repository, consumer, isLocal, alertClient, logger)
|
||||
app := fiber.New(fiber.Config{DisableStartupMessage: true})
|
||||
|
||||
|
@ -41,7 +37,7 @@ func NewServer(guardianCheck *health.GuardianCheck, logger *zap.Logger, reposito
|
|||
api.Get("/ready", ctrl.ReadyCheck)
|
||||
return &Server{
|
||||
app: app,
|
||||
port: port,
|
||||
port: fmt.Sprintf("%d", port),
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue