Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Unable to successfully run launchd service on Mac #4498

Closed
1 of 4 tasks
petgus-lyko opened this issue Oct 30, 2023 · 3 comments
Closed
1 of 4 tasks

[Question]: Unable to successfully run launchd service on Mac #4498

petgus-lyko opened this issue Oct 30, 2023 · 3 comments
Assignees

Comments

@petgus-lyko
Copy link

Describe your question

Freshly configured agent which can run jobs without any problem

admin@lykobyggapp01 azure-agent % ./run.sh 
Scanning for tool capabilities.
Connecting to the server.
2023-10-30 09:46:51Z: Listening for Jobs

Installing service

admin@lykobyggapp01 azure-agent % ./svc.sh install
Creating launch agent in /Users/admin/Library/LaunchAgents/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01.plist
Creating /Users/admin/Library/Logs/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01
Creating /Users/admin/Library/LaunchAgents/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01.plist
Creating runsvc.sh
Creating .service
sec install complete

Everything seems ok

Trying to start the launch agent it fails.

admin@lykobyggapp01 azure-agent % ./svc.sh start
starting vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01
Failed: failed to load /Users/admin/Library/LaunchAgents/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01.plist

No error in /var/log/system.log

admin@lykobyggapp01 azure-agent % ls -la ~/Library/LaunchAgents 
total 8
drwxr-xr-x   3 admin  staff    96 Oct 30 10:31 .
drwxr-xr-x@ 74 admin  staff  2368 Oct 12 11:46 ..
-rw-r--r--   1 admin  staff   957 Oct 30 10:31 vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01.plist

admin@lykobyggapp01 azure-agent % cat  ~/Library/LaunchAgents/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/admin/azure-agent/runsvc.sh</string>
    </array>
    <key>UserName</key>
    <string>admin</string>
    <key>WorkingDirectory</key>
    <string>/Users/admin/azure-agent</string>
    <key>RunAtLoad</key>
    <true/>    
    <key>StandardOutPath</key>
    <string>/Users/admin/Library/Logs/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01/stdout.log</string>
    <key>StandardErrorPath</key>
    <string>/Users/admin/Library/Logs/vsts.agent.LykoGroup.MacMiniPool.lykobyggapp01/stderr.log</string>
    <key>EnvironmentVariables</key>
    <dict> 
      <key>VSTS_AGENT_SVC</key>
      <string>1</string>
    </dict>
  </dict>
</plist>

Versions

Installed this package
https://vstsagentpackage.azureedge.net/agent/3.227.2/vsts-agent-osx-x64-3.227.2.tar.gz

System:

admin@lykobyggapp01 azure-agent % sw_vers                                                                                                                 
ProductName:		macOS
ProductVersion:		13.3
BuildVersion:		22E252
admin@lykobyggapp01 azure-agent % sysctl -n machdep.cpu.brand_string
Apple M2

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

MacOs 13.3

Version controll system

No response

Azure DevOps Server Version (if applicable)

No response

@petgus-lyko
Copy link
Author

Should mention that running runsvc.sh which is what the plist is configured to run works.

admin@lykobyggapp01 azure-agent % ./runsvc.sh 
.path=/Users/admin/.nvm/versions/node/v18.16.0/bin:/Users/admin/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/admin/android_sdk/cmdline-tools/latest/bin:/Users/admin/android_sdk/platform-tools:/Library/Developer/CommandLineTools
Starting Agent listener with startup type: service
Started listener process
Started running service
Scanning for tool capabilities.
Connecting to the server.
2023-10-30 15:48:10Z: Listening for Jobs

@petgus-lyko
Copy link
Author

If it makes any difference I'm accessing the Mac remotely via a SSH terminal.

@vmapetr vmapetr self-assigned this Oct 30, 2023
@petgus-lyko
Copy link
Author

SOLVED!
Turns out launchctl load -w does not allow me to start when logging in via a SSH terminal.
Using TeamViewer instead I successfully managed to start the service via
./svc.sh start

Note: I was logging in as the same user all the time.

Will setup remote management for the Mac mini and work with svc.sh that way instead of connecting via SSH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants