Skip to content

Commit

Permalink
fix back compat. (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang authored Aug 31, 2016
1 parent 3d23051 commit de634ff
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions src/Agent.Listener/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,36 +109,38 @@ public async Task<int> ExecuteCommand(CommandSettings command)
bool runAsService = configManager.IsServiceConfigured();

// Run agent
if (command.Run)
{
// Error if agent not configured.
if (!configManager.IsConfigured())
{
_term.WriteError(StringUtil.Loc("AgentIsNotConfigured"));
PrintUsage();
return Constants.Agent.ReturnCode.TerminatedError;
}
//if (command.Run) // this line is current break machine provisioner.
//{

// Run the agent interactively or as service
Trace.Verbose($"Run as service: '{runAsService}'");
return await RunAsync(TokenSource.Token, settings, runAsService);
}

#if OS_WINDOWS
// this code is for migrated .net windows agent that running as windows service.
// leave the code as is untill we have a real plan for auto-migration.
if (runAsService && configManager.IsConfigured() && File.Exists(Path.Combine(IOUtil.GetBinPath(), "VsoAgentService.exe")))
// Error if agent not configured.
if (!configManager.IsConfigured())
{
// The old .net windows servicehost doesn't pass correct args while invoke Agent.Listener.exe
// When we detect the agent is a migrated .net windows agent, we will just run the agent.listener.exe even the servicehost doesn't pass correct args.
Trace.Verbose($"Run the agent for compat reason.");
return await RunAsync(TokenSource.Token, settings, runAsService);
_term.WriteError(StringUtil.Loc("AgentIsNotConfigured"));
PrintUsage();
return Constants.Agent.ReturnCode.TerminatedError;
}
#endif

Trace.Info("Doesn't match any existing command option, print usage.");
PrintUsage();
return Constants.Agent.ReturnCode.TerminatedError;
// Run the agent interactively or as service
Trace.Verbose($"Run as service: '{runAsService}'");
return await RunAsync(TokenSource.Token, settings, runAsService);

//}

// #if OS_WINDOWS
// // this code is for migrated .net windows agent that running as windows service.
// // leave the code as is untill we have a real plan for auto-migration.
// if (runAsService && configManager.IsConfigured() && File.Exists(Path.Combine(IOUtil.GetBinPath(), "VsoAgentService.exe")))
// {
// // The old .net windows servicehost doesn't pass correct args while invoke Agent.Listener.exe
// // When we detect the agent is a migrated .net windows agent, we will just run the agent.listener.exe even the servicehost doesn't pass correct args.
// Trace.Verbose($"Run the agent for compat reason.");
// return await RunAsync(TokenSource.Token, settings, runAsService);
// }
// #endif

// Trace.Info("Doesn't match any existing command option, print usage.");
// PrintUsage();
// return Constants.Agent.ReturnCode.TerminatedError;
}
finally
{
Expand Down

0 comments on commit de634ff

Please sign in to comment.