4444import com .thoughtworks .go .server .service .AgentBuildingInfo ;
4545import com .thoughtworks .go .server .service .AgentRuntimeInfo ;
4646import com .thoughtworks .go .server .service .ElasticAgentRuntimeInfo ;
47- import com .thoughtworks .go .util .*;
47+ import com .thoughtworks .go .util .HttpService ;
48+ import com .thoughtworks .go .util .SubprocessLogger ;
49+ import com .thoughtworks .go .util .SystemEnvironment ;
50+ import com .thoughtworks .go .util .SystemUtil ;
51+ import com .thoughtworks .go .util .TimeProvider ;
52+ import com .thoughtworks .go .util .URLService ;
53+ import com .thoughtworks .go .util .ZipUtil ;
4854import com .thoughtworks .go .websocket .Action ;
4955import com .thoughtworks .go .websocket .Message ;
5056import com .thoughtworks .go .websocket .MessageCallback ;
5763
5864import java .io .File ;
5965import java .io .IOException ;
66+ import java .net .Socket ;
67+ import java .net .URL ;
6068import java .security .GeneralSecurityException ;
6169import java .util .Map ;
6270import java .util .concurrent .ConcurrentHashMap ;
@@ -102,7 +110,7 @@ public AgentController(BuildRepositoryRemote server, GoArtifactsManipulator mani
102110 this .taskExtension = taskExtension ;
103111 this .websocketService = websocketService ;
104112 this .httpService = httpService ;
105- ipAddress = SystemUtil .getFirstLocalNonLoopbackIpAddress ( );
113+ ipAddress = SystemUtil .getClientIp ( systemEnvironment . getServiceUrl () );
106114 hostName = SystemUtil .getLocalhostNameOrRandomNameIfNotFound ();
107115 this .server = server ;
108116 this .manipulator = manipulator ;
@@ -114,6 +122,7 @@ public AgentController(BuildRepositoryRemote server, GoArtifactsManipulator mani
114122 this .agentAutoRegistrationProperties = new AgentAutoRegistrationPropertiesImpl (new File ("config" , "autoregister.properties" ));
115123 }
116124
125+
117126 void init () throws IOException {
118127 websocketService .setController (this );
119128 createPipelinesFolderIfNotExist ();
@@ -360,11 +369,11 @@ private void runBuild(BuildSettings buildSettings) {
360369
361370 private void cancelBuild () throws InterruptedException {
362371 BuildSession build = this .buildSession .get ();
363- if (build == null ) {
372+ if (build == null ) {
364373 return ;
365374 }
366375 agentRuntimeInfo .cancel ();
367- if (!build .cancel (30 , TimeUnit .SECONDS )) {
376+ if (!build .cancel (30 , TimeUnit .SECONDS )) {
368377 LOG .error ("Waited 30 seconds for canceling job finish, but the job is still running. Maybe canceling job does not work as expected, here is buildSession details: " + buildSession .get ());
369378 }
370379 }
0 commit comments