What is best practice to perform a clean shutdown of a Wakanda server via OS X shell scripting?
This would be with a solution currently loaded and operating.
When running Wakanda Server as a background process, you can cleanly stop it using the process ID and the kill -sigterm command.
SIGTERM
The SIGTERM signal is sent to a process to request its termination. Unlike the SIGKILL signal, it can be caught and interpreted or ignored by the process. This allows the process to perform nice termination releasing resources and saving state if appropriate. SIGINT is nearly identical to SIGTERM.
Here is some sample code that demonstrates this:
ps -A | grep wakanda-server
kill -SIGTERM pid_from_line_above
Note: you must replace pid_from_line_above with the PID that is returned by ps -A | grep wakanda-server
For your bash script, maybe something like this would work:
killall -TERM /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server
sleep 15
killall -KILL /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server
The script first sends the normal termination signal to the process, then waits 15 seconds before sending the kill signal to the process forcing it to quit.
Reminder: kill -SIGKILL PID cannot be caught or ignored.
SIGKILL
The SIGKILL signal is sent to a process to cause it to terminate immediately (kill). In contrast to SIGTERM and SIGINT, this signal cannot be caught or ignored, and the receiving process cannot perform any clean-up upon receiving this signal.
Although a better way of doing this may be to use a LaunchDaemon as suggested in response to osx startupitems shell script does not launch application
See also: Administrating Wakanda Server for Unix