mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
refactor: consolidated configs
This commit is contained in:
2
.github/workflows/docker-crawlab.yml
vendored
2
.github/workflows/docker-crawlab.yml
vendored
@@ -34,6 +34,7 @@ jobs:
|
||||
workflow_changed: ${{ steps.check_changed_files.outputs.workflow_changed }}
|
||||
base_image_changed: ${{ steps.check_changed_files.outputs.base_image_changed }}
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
test_script: ${{ steps.test_config.outputs.test_script }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -299,6 +300,7 @@ jobs:
|
||||
image: ghcr.io/${{ github.repository_owner }}/crawlab:${{ needs.setup.outputs.version }}
|
||||
env:
|
||||
CRAWLAB_NODE_MASTER: N
|
||||
CRAWLAB_MASTER_HOST: master
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -36,9 +36,7 @@ func (app *Api) Init() {
|
||||
|
||||
func (app *Api) Start() {
|
||||
// address
|
||||
host := utils.GetServerHost()
|
||||
port := utils.GetServerPort()
|
||||
address := net.JoinHostPort(host, port)
|
||||
address := utils.GetServerAddress()
|
||||
|
||||
// http server
|
||||
app.srv = &http.Server{
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultServerHost = "0.0.0.0"
|
||||
DefaultServerPort = "8000"
|
||||
DefaultWorkspace = "crawlab_workspace"
|
||||
DefaultTaskLogPath = "/var/log/crawlab/tasks"
|
||||
DefaultServerHost = "0.0.0.0"
|
||||
DefaultServerPort = 8000
|
||||
DefaultGrpcHost = "localhost"
|
||||
DefaultGrpcPort = "9666"
|
||||
DefaultGrpcPort = 9666
|
||||
DefaultGrpcServerHost = "127.0.0.1"
|
||||
DefaultGrpcServerPort = 9666
|
||||
DefaultAuthKey = "Crawlab2024!"
|
||||
DefaultApiEndpoint = "http://localhost:8000"
|
||||
DefaultApiAllowOrigin = "*"
|
||||
@@ -71,7 +75,10 @@ func IsPro() bool {
|
||||
}
|
||||
|
||||
func GetWorkspace() string {
|
||||
return viper.GetString("workspace")
|
||||
if res := viper.GetString("workspace"); res != "" {
|
||||
return res
|
||||
}
|
||||
return DefaultWorkspace
|
||||
}
|
||||
|
||||
func GetTaskLogPath() string {
|
||||
@@ -81,18 +88,18 @@ func GetTaskLogPath() string {
|
||||
return DefaultTaskLogPath
|
||||
}
|
||||
|
||||
func GetServerHost() string {
|
||||
if res := viper.GetString("server.host"); res != "" {
|
||||
return res
|
||||
func GetServerAddress() string {
|
||||
host := viper.GetString("server.host")
|
||||
if host == "" {
|
||||
host = DefaultServerHost
|
||||
}
|
||||
return DefaultServerHost
|
||||
}
|
||||
|
||||
func GetServerPort() string {
|
||||
if res := viper.GetString("server.port"); res != "" {
|
||||
return res
|
||||
port := viper.GetInt("server.port")
|
||||
if port == 0 {
|
||||
port = DefaultServerPort
|
||||
}
|
||||
return DefaultServerPort
|
||||
|
||||
return fmt.Sprintf("%s:%d", host, port)
|
||||
}
|
||||
|
||||
func GetMasterHost() string {
|
||||
@@ -101,7 +108,6 @@ func GetMasterHost() string {
|
||||
|
||||
func GetGrpcAddress() string {
|
||||
host := viper.GetString("grpc.host")
|
||||
port := viper.GetString("grpc.port")
|
||||
if host == "" {
|
||||
masterHost := GetMasterHost()
|
||||
if masterHost != "" {
|
||||
@@ -110,14 +116,27 @@ func GetGrpcAddress() string {
|
||||
host = DefaultGrpcHost
|
||||
}
|
||||
}
|
||||
if port == "" {
|
||||
|
||||
port := viper.GetInt("grpc.port")
|
||||
if port == 0 {
|
||||
port = DefaultGrpcPort
|
||||
}
|
||||
return host + ":" + port
|
||||
|
||||
return fmt.Sprintf("%s:%d", host, port)
|
||||
}
|
||||
|
||||
func GetGrpcServerAddress() string {
|
||||
return viper.GetString("grpc.server.address")
|
||||
host := viper.GetString("grpc.server.host")
|
||||
if host == "" {
|
||||
host = DefaultGrpcServerHost
|
||||
}
|
||||
|
||||
port := viper.GetInt("grpc.server.port")
|
||||
if port == 0 {
|
||||
port = DefaultGrpcServerPort
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s:%d", host, port)
|
||||
}
|
||||
|
||||
func GetAuthKey() string {
|
||||
|
||||
Reference in New Issue
Block a user