I am developing an app, in this case for macOS. My app has two parts:
- A GUI
- A Server
From the GUI i can start and stop the serve. My problem is that i need the server starts when the mac boots. Using the LaunchAgents i got to launch it when the user logins on, but i need to initiate it before.
I saw that i need to saving my .plis inside of /Library/LaunchDaemons. I did it but when i restart the computer the server didn t initiate.
I checked that my service gave me the status 1 so, it didn t launch correctly. Maybe the failure is inside the plist... but i dont understand why it works in LaunchAgent and not inside LaunchDaemons
My plist is:
<?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>com.turnoffpc.turnoffpcplist</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Turn Off PC.app/Contents/Resources/Turn Off PC/Server/dist/turn_off_pc_server.app/Contents/MacOS/turn_off_pc_server</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
For loading the service im using the following sh:
#!/bin/bash
# Copiar el archivo plist a /Library/LaunchDaemons/
sudo cp com.turnoffpc.turnoffpcplist.plist /Library/LaunchDaemons/
# Establecer los permisos adecuados
sudo chown root:wheel /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist
sudo chmod 644 /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist
# Descargar y luego cargar el servicio utilizando launchctl
sudo launchctl unload /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist
sudo launchctl load /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist
I checked that the service is in the correct location
The path to my app is: inside /Applications
Turn Off PC.app
- Resources
- Turn Off PC - Server - dist - turn_off_pc_server.app - Contents - MacOS - turn_off_pc_server
Someone sees the error or the thing that i am doing wrong? Thanks in advance