I have created a LaunchDaemon service which runs a application
Here is my com.testapp.plist:
It is working fine. But when I reboot my system, launchdaemon start my application but it kills the application.
Log which I get in console is,
I also checked application running state from Activity Monitor which shows that application is running.
Also checked the daemon state by
which also shows that daemon is also running.
I am not able to get the main cause of this issue .
Please help.
Thanks in advance.
sudo launchctl load /Library/LaunchDaemons/com.testapp.plist
Here is my com.testapp.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>com.testapp</string>
<key>OnDemand</key>
<false/>
<key>UserName</key>
<string>root</string>
<key>GroupName</key>
<string>wheel</string>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/OutputLog1.log</string>
<key>StandardOutPath</key>
<string>/var/log/OutputLog2.log</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/TestApplication/Test.app/Contents/MacOS/Test</string>
</array>
</dict>
</plist>
<!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.testapp</string>
<key>OnDemand</key>
<false/>
<key>UserName</key>
<string>root</string>
<key>GroupName</key>
<string>wheel</string>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/OutputLog1.log</string>
<key>StandardOutPath</key>
<string>/var/log/OutputLog2.log</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/TestApplication/Test.app/Contents/MacOS/Test</string>
</array>
</dict>
</plist>
It is working fine. But when I reboot my system, launchdaemon start my application but it kills the application.
Log which I get in console is,
20/03/17 7:15:25.239 PM Test[50]: Untrusted apps are not allowed to connect to Window Server before login.
20/03/17 7:15:25.239 PM Test[50]: Set a breakpoint at CGSLogError to catch errors as they are logged.
20/03/17 7:15:25.239 PM Test[50]: On-demand launch of the Window Server is allowed for root user only.
20/03/17 7:15:25.239 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:25.239 PM Test[50]: On-demand launch of the Window Server is allowed for root user only.
20/03/17 7:15:25.239 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:25.239 PM Test[50]: This user is not allowed access to the window system right now.
20/03/17 7:15:34.721 PM Test[50]: RegisterApplication(), FAILED TO establish the default connection to the WindowServer, CGSDefaultConnection() is NULL.
20/03/17 7:15:34.732 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.732 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.735 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.735 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.735 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.736 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.736 PM Test[50]: Invalid Connection ID 0
20/03/17 7:15:34.970 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:34.970 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:34.970 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:34.972 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.972 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.972 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.976 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.977 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:25.239 PM Test[50]: Set a breakpoint at CGSLogError to catch errors as they are logged.
20/03/17 7:15:25.239 PM Test[50]: On-demand launch of the Window Server is allowed for root user only.
20/03/17 7:15:25.239 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:25.239 PM Test[50]: On-demand launch of the Window Server is allowed for root user only.
20/03/17 7:15:25.239 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:25.239 PM Test[50]: This user is not allowed access to the window system right now.
20/03/17 7:15:34.721 PM Test[50]: RegisterApplication(), FAILED TO establish the default connection to the WindowServer, CGSDefaultConnection() is NULL.
20/03/17 7:15:34.732 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.732 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.735 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.735 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.735 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.736 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.736 PM Test[50]: Invalid Connection ID 0
20/03/17 7:15:34.970 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:34.970 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:34.970 PM Test[50]: CGSLookupServerRootPort: Failed to look up the port for "com.apple.windowserver.active" (1102)
20/03/17 7:15:34.972 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.972 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.972 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.976 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
20/03/17 7:15:34.977 PM Test[50]: CGSConnectionByID: 0 is not a valid connection ID.
I also checked application running state from Activity Monitor which shows that application is running.
Also checked the daemon state by
sudo launchctl list | grep testapp
which also shows that daemon is also running.
I am not able to get the main cause of this issue .
Please help.
Thanks in advance.