(options pluginWorkerRunOptions)
| 41 | } |
| 42 | |
| 43 | func runPluginWorkerWithOptions(options pluginWorkerRunOptions) bool { |
| 44 | util.LoadConfiguration("security", false) |
| 45 | |
| 46 | options.AdminServer = strings.TrimSpace(options.AdminServer) |
| 47 | if options.AdminServer == "" { |
| 48 | options.AdminServer = "localhost:23646" |
| 49 | } |
| 50 | |
| 51 | options.JobTypes = strings.TrimSpace(options.JobTypes) |
| 52 | if options.JobTypes == "" { |
| 53 | options.JobTypes = defaultPluginWorkerJobTypes |
| 54 | } |
| 55 | |
| 56 | if options.Heartbeat <= 0 { |
| 57 | options.Heartbeat = 15 * time.Second |
| 58 | } |
| 59 | if options.Reconnect <= 0 { |
| 60 | options.Reconnect = 5 * time.Second |
| 61 | } |
| 62 | if options.MaxDetect <= 0 { |
| 63 | options.MaxDetect = 1 |
| 64 | } |
| 65 | if options.MaxExecute <= 0 { |
| 66 | options.MaxExecute = 4 |
| 67 | } |
| 68 | options.MetricsIP = strings.TrimSpace(options.MetricsIP) |
| 69 | if options.MetricsIP == "" { |
| 70 | options.MetricsIP = "0.0.0.0" |
| 71 | } |
| 72 | |
| 73 | resolvedAdminServer := resolvePluginWorkerAdminServer(options.AdminServer) |
| 74 | if resolvedAdminServer != options.AdminServer { |
| 75 | fmt.Printf("Resolved admin worker gRPC endpoint: %s -> %s\n", options.AdminServer, resolvedAdminServer) |
| 76 | } |
| 77 | |
| 78 | dialOption := security.LoadClientTLS(util.GetViper(), "grpc.worker") |
| 79 | workerID, err := resolvePluginWorkerID(options.WorkerID, options.WorkingDir) |
| 80 | if err != nil { |
| 81 | glog.Errorf("Failed to resolve plugin worker ID: %v", err) |
| 82 | return false |
| 83 | } |
| 84 | |
| 85 | handlers, err := buildPluginWorkerHandlers(options.JobTypes, dialOption, options.MaxExecute, options.WorkingDir) |
| 86 | if err != nil { |
| 87 | glog.Errorf("Failed to build plugin worker handlers: %v", err) |
| 88 | return false |
| 89 | } |
| 90 | worker, err := pluginworker.NewWorker(pluginworker.WorkerOptions{ |
| 91 | AdminServer: resolvedAdminServer, |
| 92 | WorkerID: workerID, |
| 93 | WorkerVersion: version.Version(), |
| 94 | WorkerAddress: options.Address, |
| 95 | HeartbeatInterval: options.Heartbeat, |
| 96 | ReconnectDelay: options.Reconnect, |
| 97 | MaxDetectionConcurrency: options.MaxDetect, |
| 98 | MaxExecutionConcurrency: options.MaxExecute, |
| 99 | GrpcDialOption: dialOption, |
| 100 | Handlers: handlers, |
no test coverage detected