generated from PenaSide/GolangTemplate
ci: fix env hosts
This commit is contained in:
parent
6430479620
commit
6e156ce3a7
@ -12,7 +12,7 @@ lint:
|
|||||||
- go install github.com/vektra/mockery/v2@v2.26.0
|
- go install github.com/vektra/mockery/v2@v2.26.0
|
||||||
- go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4
|
- go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4
|
||||||
script:
|
script:
|
||||||
- go generate ./...
|
- go generate ./internal/...
|
||||||
- golangci-lint version
|
- golangci-lint version
|
||||||
- golangci-lint run ./internal/...
|
- golangci-lint run ./internal/...
|
||||||
|
|
||||||
|
2
Makefile
2
Makefile
@ -14,7 +14,7 @@ install: ## install all go dependencies
|
|||||||
|
|
||||||
generate: ## generate grpc proto for golang
|
generate: ## generate grpc proto for golang
|
||||||
buf generate
|
buf generate
|
||||||
go generate ./internal/swagger
|
go generate ./internal/interface/swagger
|
||||||
|
|
||||||
test: ## run all layers tests
|
test: ## run all layers tests
|
||||||
@make test.unit
|
@make test.unit
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os/signal"
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/app"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/app"
|
||||||
@ -15,21 +11,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
|
||||||
logger, err := zap.NewProduction(zap.AddStacktrace(zap.DPanicLevel))
|
logger, err := zap.NewProduction(zap.AddStacktrace(zap.DPanicLevel))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to init zap logger: %v", err)
|
log.Fatalf("failed to init zap logger: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer cancel()
|
|
||||||
defer func() {
|
|
||||||
if syncErr := logger.Sync(); syncErr != nil {
|
|
||||||
if !errors.Is(syncErr, syscall.EBADF) && !errors.Is(syncErr, syscall.ENOTTY) {
|
|
||||||
log.Fatalf("failed to sync zap logger: %v", syncErr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
config, err := initialize.Configuration(".env.test")
|
config, err := initialize.Configuration(".env.test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal("failed to init config: %v", zap.Error(err))
|
logger.Fatal("failed to init config: %v", zap.Error(err))
|
||||||
@ -42,7 +28,7 @@ func main() {
|
|||||||
|
|
||||||
fmt.Println("env configuration: \n", string(configJSON))
|
fmt.Println("env configuration: \n", string(configJSON))
|
||||||
|
|
||||||
if err := app.Run(ctx, config, logger); err != nil {
|
if err := app.Run(config, logger); err != nil {
|
||||||
logger.Fatal("failed to run app: %v", zap.Error(err))
|
logger.Fatal("failed to run app: %v", zap.Error(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,42 @@
|
|||||||
version: "3.3"
|
version: "3.3"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
pena-social-auth-service:
|
customer-app-staging:
|
||||||
container_name: pena-social-auth-service
|
hostname: customer-service-staging
|
||||||
restart: unless-stopped
|
container_name: customer-service-staging
|
||||||
tty: true
|
|
||||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
|
||||||
|
tty: true
|
||||||
environment:
|
environment:
|
||||||
- ENVIRONMENT=staging
|
|
||||||
|
|
||||||
- HTTP_HOST=0.0.0.0
|
- HTTP_HOST=0.0.0.0
|
||||||
- HTTP_PORT=8000
|
- HTTP_PORT=8065
|
||||||
|
|
||||||
|
- GRPC_HOST=0.0.0.0
|
||||||
|
- GRPC_PORT=9085
|
||||||
|
- GRPC_DOMEN=http://customer-service:9085
|
||||||
|
|
||||||
- MONGO_HOST=10.6.0.11
|
- MONGO_HOST=10.6.0.11
|
||||||
- MONGO_PORT=27017
|
- MONGO_PORT=27017
|
||||||
- MONGO_USER=$MONGO_USER
|
- MONGO_USER=$MONGO_USER
|
||||||
- MONGO_PASSWORD=$MONGO_PASSWORD
|
- MONGO_PASSWORD=$MONGO_PASSWORD
|
||||||
- MONGO_DB_NAME=socialAuth
|
- MONGO_DB_NAME=customer
|
||||||
- MONGO_AUTH=socialAuth
|
- MONGO_AUTH=customer
|
||||||
|
|
||||||
|
- AUTH_MICROSERVICE_USER_URL=https://admin.pena.digital/user
|
||||||
|
- HUBADMIN_MICROSERVICE_TARIFF_URL=https://admin.pena.digital/strator/tariff
|
||||||
|
- CURRENCY_MICROSERVICE_TRANSLATE_URL=http://10.6.0.11:3131/change
|
||||||
|
- DISCOUNT_MICROSERVICE_GRPC_HOST=10.6.0.11:9001
|
||||||
|
- PAYMENT_MICROSERVICE_GRPC_HOST=10.6.0.11:9085
|
||||||
|
|
||||||
- JWT_PUBLIC_KEY=$JWT_PUBLIC_KEY
|
- JWT_PUBLIC_KEY=$JWT_PUBLIC_KEY
|
||||||
- JWT_ISSUER=pena-auth-service
|
- JWT_ISSUER=pena-auth-service
|
||||||
- JWT_AUDIENCE=pena
|
- JWT_AUDIENCE=pena
|
||||||
expose:
|
ports:
|
||||||
- 8000
|
- 8065:8065
|
||||||
|
- 9065:9065
|
||||||
networks:
|
networks:
|
||||||
- marketplace_penahub_frontend
|
- marketplace_penahub_frontend
|
||||||
|
- default
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
marketplace_penahub_frontend:
|
marketplace_penahub_frontend:
|
||||||
external: true
|
external: true
|
@ -2,14 +2,17 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize"
|
||||||
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/server"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/server"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/swagger"
|
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/closer"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/closer"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/mongo"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/mongo"
|
||||||
@ -19,7 +22,17 @@ const (
|
|||||||
shutdownTimeout = 5 * time.Second
|
shutdownTimeout = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run(ctx context.Context, config *models.Config, logger *zap.Logger) error {
|
func Run(config *models.Config, logger *zap.Logger) (appErr error) {
|
||||||
|
defer func() {
|
||||||
|
if recovered := recover(); recovered != nil {
|
||||||
|
appErr = errors.New("recovered panic on application run")
|
||||||
|
logger.Error("recovered panic on application run", zap.Any("recovered", recovered))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
closer := closer.New()
|
closer := closer.New()
|
||||||
|
|
||||||
mongoDB, err := mongo.Connect(ctx, &mongo.ConnectDeps{
|
mongoDB, err := mongo.Connect(ctx, &mongo.ConnectDeps{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package initialize
|
package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/swagger"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAPI(controllers Controllers) *swagger.API {
|
func NewAPI(controllers Controllers) *swagger.API {
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
||||||
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/swagger"
|
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/echotools"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/echotools"
|
||||||
)
|
)
|
||||||
|
|
||||||
type accountService interface {
|
type accountService interface {
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
||||||
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/swagger"
|
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/echotools"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/echotools"
|
||||||
)
|
)
|
||||||
|
|
||||||
type currencyService interface {
|
type currencyService interface {
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
||||||
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/swagger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type historyService interface {
|
type historyService interface {
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/utils/echotools"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/echotools"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate oapi-codegen --config api.yaml ../../openapi.yaml
|
//go:generate oapi-codegen --config api.yaml ../../../openapi.yaml
|
||||||
//go:generate oapi-codegen --config models.yaml ../../openapi.yaml
|
//go:generate oapi-codegen --config models.yaml ../../../openapi.yaml
|
||||||
|
|
||||||
type accountController interface {
|
type accountController interface {
|
||||||
RemoveAccount(ctx echo.Context) error
|
RemoveAccount(ctx echo.Context) error
|
@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/errors"
|
||||||
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/interface/swagger"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
|
||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/swagger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DepsHTTP struct {
|
type DepsHTTP struct {
|
||||||
|
@ -50,6 +50,8 @@ func Connect(ctx context.Context, deps *ConnectDeps) (*mongo.Database, error) {
|
|||||||
}).
|
}).
|
||||||
SetMonitor(cmdMonitor)
|
SetMonitor(cmdMonitor)
|
||||||
|
|
||||||
|
fmt.Println(connectionOptions.GetURI())
|
||||||
|
|
||||||
ticker := time.NewTicker(1 * time.Second)
|
ticker := time.NewTicker(1 * time.Second)
|
||||||
timeoutExceeded := time.After(deps.Timeout)
|
timeoutExceeded := time.After(deps.Timeout)
|
||||||
|
|
||||||
@ -65,10 +67,9 @@ func Connect(ctx context.Context, deps *ConnectDeps) (*mongo.Database, error) {
|
|||||||
|
|
||||||
log.Printf("failed to connect to db <%s>: %s", mongoURI.String(), err.Error())
|
log.Printf("failed to connect to db <%s>: %s", mongoURI.String(), err.Error())
|
||||||
case <-timeoutExceeded:
|
case <-timeoutExceeded:
|
||||||
return nil, fmt.Errorf("db connection <%s> failed after %d timeout", mongoURI, deps.Timeout)
|
return nil, fmt.Errorf("db connection <%s> failed after %d timeout", mongoURI.String(), deps.Timeout)
|
||||||
default:
|
default:
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user