Osx startupitems shell script does not start application

I am trying to run a faceless server application using a project associated with it using a shell script in OSX 10.10.4.

The shell script is installed in an executable file.

When starting up, nothing happens to start Wakanda \ Server.app/Contents/MacOS/Wakanda \ Server.

Please help me do this work.

The shell script is located at:

Macintosh HD:Library:StartupItems:DispatchStartup:DispatchStartup.sh 

The contents of this shell script:

 #!/bin/sh . /etc/rc.common # The start subroutine StartService() { # Insert your start command below. For example: /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server --solution=/Applications/Dispatch/Dispatch\ Solution/Dispatch.waSolution # End example. } # The stop subroutine StopService() { # Insert your stop command(s) below. For example: killall -TERM /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server sleep 15 killall -9 /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server # End example. } # The restart subroutine RestartService() { # Insert your start command below. For example: killall -HUP /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server # End example. } RunService "$1" 

// --------------------------------------------- --- -------------------

// next to the shell script is StartParameters.plist // -------------------------------------- ---------- --------------------

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> <plist version="0.9"> <dict> <key>Description</key> <string>Wakanda Server</string> <key>OrderPreference</key> <string>Late</string> <key>Provides</key> <array> <string>Web service to database and objects</string> </array> <key>Uses</key> <array> <string>Network</string> </array> </dict> </plist> 
+1
source share
1 answer

Autostart items are deprecated in favor of starting the daemon with OS X v10.4, and they seem to have finally been completely disabled in v10 +0.10. The best option is to create a launch daemon instead. This will be a properties file (.plist) in / Library / LaunchDaemons / containing instructions on what to start and when to start it.

This will be a little more complicated than usual, because the launch system is recommended to monitor running tasks, which requires that they do not fall into the background, and I do not see any obstacles to preventing the use of the Wakanda server myself. You can get around this by adding instructions to the .plist so you don’t keep it alive, and β€œabandon” your process group (ie. Do not kill any remaining background processes that it spawns). There may also be a problem that there is no good way to tell her to wait until the network starts working. But this is basically a problem if he tries to listen for specific IP addresses or interfaces; if it just listens for 0.0.0.0 (i.e. all IP addresses on the computer), that is not a problem, because it just picks up the interfaces as they appear.

I think the .plist would look something like this:

 <?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>Disabled</key> <false/> <key>Label</key> <string>local.wakanda-server</string> <key>ProgramArguments</key> <array> <string>/Applications/Wakanda Server.app/Contents/MacOS/Wakanda Server</string> <string>--solution=/Applications/Dispatch/Dispatch Solution/Dispatch.waSolution</string> </array> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <false/> <key>AbandonProcessGroup</key> <false/> </dict> </plist> 

put it in /Library/LaunchDaemons/local.wakand-server.plist, set root ownership: wheel, permissions to 644 and then reload or manually load it with sudo launchctl load /Library/LaunchDaemons/local.wakanda-server.plist .

+1
source

Source: https://habr.com/ru/post/1244013/


All Articles