diff --git a/scripts/run_server.sh b/scripts/run_server.sh index ec9e755..921cb67 100644 --- a/scripts/run_server.sh +++ b/scripts/run_server.sh @@ -1,5 +1,17 @@ #!/usr/bin/env bash set -e cd "$(dirname "$0")/.."/server +set -a +[ -f .env.local ] && source .env.local +set +a +if [ "${SKIP_YMT:-0}" = "1" ]; then + unset YMT_DB_USER YMT_DB_PASSWORD YMT_DB_HOST YMT_DB_PORT YMT_DB_NAME +fi go mod tidy -go run ./cmd/server +if [ "${BUILD:-0}" = "1" ]; then + mkdir -p bin + go build -o bin/marketing-data-server ./cmd/server + PORT=${PORT:-8077} ./bin/marketing-data-server +else + go run ./cmd/server +fi diff --git a/server/bin/marketing-data-server b/server/bin/marketing-data-server index 565a89c..e411369 100755 Binary files a/server/bin/marketing-data-server and b/server/bin/marketing-data-server differ diff --git a/server/internal/db/mysql.go b/server/internal/db/mysql.go index 54f5379..99d1e2d 100644 --- a/server/internal/db/mysql.go +++ b/server/internal/db/mysql.go @@ -1,17 +1,15 @@ package db import ( - "database/sql" - _ "github.com/go-sql-driver/mysql" + "database/sql" + + _ "github.com/go-sql-driver/mysql" ) func ConnectMySQL(dsn string) (*sql.DB, error) { - if dsn == "" { - return sql.Open("mysql", "invalid:invalid@tcp(localhost:3306)/invalid") - } - db, err := sql.Open("mysql", dsn) - if err != nil { - return nil, err - } - return db, nil + db, err := sql.Open("mysql", dsn) + if err != nil { + return nil, err + } + return db, nil }