Skip to content

Commit

Permalink
Merge pull request #99 from Microsoft/users/stiliev/servicepath
Browse files Browse the repository at this point in the history
Store the PATH environment variable
  • Loading branch information
Stan Iliev committed Apr 28, 2016
2 parents 8914b3e + 6e0f1ba commit 1cc5ed7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 6 additions & 5 deletions src/Agent.Listener/Configuration/LinuxServiceControlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ public override bool ConfigureService(
var unitContent = File.ReadAllText(Path.Combine(IOUtil.GetBinPath(), VstsAgentServiceTemplate));
var tokensToReplace = new Dictionary<string, string>
{
{ "{Description}", settings.ServiceDisplayName },
{ "{BinDirectory}", IOUtil.GetBinPath() },
{ "{AgentRoot}", IOUtil.GetRootPath() },
{ "{ExternalsDirectory}", IOUtil.GetExternalsPath() },
{ "{User}", GetCurrentLoginName() }
{ "{{Description}}", settings.ServiceDisplayName },
{ "{{BinDirectory}}", IOUtil.GetBinPath() },
{ "{{AgentRoot}}", IOUtil.GetRootPath() },
{ "{{ExternalsDirectory}}", IOUtil.GetExternalsPath() },
{ "{{User}}", GetCurrentLoginName() },
{ "{{Path}}", Environment.GetEnvironmentVariable("PATH") }
};

unitContent = tokensToReplace.Aggregate(
Expand Down
10 changes: 5 additions & 5 deletions src/Misc/layoutbin/vsts.agent.service.template
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Unit]
Description={Description}
Description={{Description}}
After=network.target

[Service]
ExecStart={ExternalsDirectory}/node/bin/node {BinDirectory}/AgentService.js
User={User}
Environment=PATH=/usr/bin:/usr/local/bin
ExecStart={{ExternalsDirectory}}/node/bin/node {{BinDirectory}}/AgentService.js
User={{User}}
Environment=PATH={{Path}}
Environment=NODE_ENV=production
WorkingDirectory={AgentRoot}
WorkingDirectory={{AgentRoot}}

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ public void VerifyLinuxServiceConfigurationFileContent()
[Service]
ExecStart={0}/node/bin/node {1}/AgentService.js
User={3}
Environment=PATH=/usr/bin:/usr/local/bin
Environment=PATH={4}
Environment=NODE_ENV=production
WorkingDirectory={2}
[Install]
WantedBy=multi-user.target
", IOUtil.GetExternalsPath(), IOUtil.GetBinPath(), IOUtil.GetRootPath(), testUser);
", IOUtil.GetExternalsPath(), IOUtil.GetBinPath(), IOUtil.GetRootPath(), testUser, Environment.GetEnvironmentVariable("PATH"));

var agentSettings = new AgentSettings
{
Expand Down

0 comments on commit 1cc5ed7

Please sign in to comment.