refactor: improve logging messages and update configuration constants

- Updated logging messages in GrpcClient to provide clearer context, changing "ready" to "client is now ready" and "stopped" to "client has stopped".
- Refactored test setup in runner_test.go to remove unnecessary error checks during gRPC client start for cleaner code.
- Renamed GetDependencySetupScriptRoot to GetInstallRoot and updated related constants for better clarity and consistency in configuration management.
This commit is contained in:
Marvin Zhang
2024-12-23 18:19:08 +08:00
parent c3f4c4ae05
commit 99ed4396d1
3 changed files with 27 additions and 27 deletions

View File

@@ -93,11 +93,11 @@ func (c *GrpcClient) WaitForReady() {
select {
case <-ticker.C:
if c.IsReady() {
c.logger.Debugf("ready")
c.logger.Debugf("client is now ready")
return
}
case <-c.stop:
c.logger.Errorf("stopped")
c.logger.Errorf("client has stopped")
}
}
}

View File

@@ -36,7 +36,7 @@ func setupGrpc(t *testing.T) {
require.Nil(t, err)
// Start a gRPC client
err = client.GetGrpcClient().Start()
client.GetGrpcClient().Start()
require.Nil(t, err)
// Cleanup

View File

@@ -11,27 +11,27 @@ import (
)
const (
DefaultWorkspace = "crawlab_workspace"
DefaultTaskLogPath = "/var/log/crawlab/tasks"
DefaultServerHost = "0.0.0.0"
DefaultServerPort = 8000
DefaultGrpcHost = "localhost"
DefaultGrpcPort = 9666
DefaultGrpcServerHost = "0.0.0.0"
DefaultGrpcServerPort = 9666
DefaultAuthKey = "Crawlab2024!"
DefaultApiEndpoint = "http://localhost:8000"
DefaultApiAllowOrigin = "*"
DefaultApiAllowCredentials = "true"
DefaultApiAllowMethods = "DELETE, POST, OPTIONS, GET, PUT"
DefaultApiAllowHeaders = "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
DefaultApiPort = 8080
DefaultApiPath = "/api"
DefaultNodeMaxRunners = 0 // 0 means no limit
DefaultDependencySetupScriptRoot = "/app/install"
MetadataConfigDirName = ".crawlab"
MetadataConfigName = "config.json"
PyenvRoot = "/root/.pyenv"
DefaultWorkspace = "crawlab_workspace"
DefaultTaskLogPath = "/var/log/crawlab/tasks"
DefaultServerHost = "0.0.0.0"
DefaultServerPort = 8000
DefaultGrpcHost = "localhost"
DefaultGrpcPort = 9666
DefaultGrpcServerHost = "0.0.0.0"
DefaultGrpcServerPort = 9666
DefaultAuthKey = "Crawlab2024!"
DefaultApiEndpoint = "http://localhost:8000"
DefaultApiAllowOrigin = "*"
DefaultApiAllowCredentials = "true"
DefaultApiAllowMethods = "DELETE, POST, OPTIONS, GET, PUT"
DefaultApiAllowHeaders = "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
DefaultApiPort = 8080
DefaultApiPath = "/api"
DefaultNodeMaxRunners = 0 // 0 means no limit
DefaultInstallRoot = "/app/install"
MetadataConfigDirName = ".crawlab"
MetadataConfigName = "config.json"
PyenvRoot = "/root/.pyenv"
)
func IsDev() bool {
@@ -245,9 +245,9 @@ func GetMetadataConfigPath() string {
return filepath.Join(homeDirPath, MetadataConfigDirName, MetadataConfigName)
}
func GetDependencySetupScriptRoot() string {
if res := viper.GetString("dependency.setupScriptRoot"); res != "" {
func GetInstallRoot() string {
if res := viper.GetString("install.root"); res != "" {
return res
}
return DefaultDependencySetupScriptRoot
return DefaultInstallRoot
}