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.
The best practice for the upcoming release 1.1.0 :
applicationWillStop
event on a service to handle app specific closing logic service wakanda stop
for Ubuntu and a normal kill
for Mac OS ( kill -9
should always be the last resort after some kind of timeout but this should not be necessary anymore)The best practice for the current release 1.0.x :
HTTP Request Handler
or another method (make sure to secure this very well and accept connections only from localhost)service wakanda stop
for Ubuntu and a normal kill
for Mac OS ( kill -9
should always be the last resort after some kind of timeout but this should not be necessary anymore)
More details :
We should make a distinction between an HTTP Server like Apache and an application server like Wakanda Server.
For example, when you are using a SharedWorker
in Wakanda, your are creating a separate thread that is going to run some code. Suppose that worker is doing some kind of critical data manipulation. If you let the server close that worker for you, it might cause data incoherence in your application. You should therefore handle any business logic specific "clean" close before the server stops the app.
Starting from version 1.1.0, instead of creating a special HTTP Request Handler
that you can call to prepare the server's stop, you can use a service that handles the event applicationWillStop
.
When the server receives a blockable kill signal ( TERM, QUIT, INT ), it will start the stopping process ( The following is true for version 1.1.x of Wakanda Digital App Factory ) :
applicationWillStop
httpServerWillStop
In the versions prior to 1.1.0 the server asks the workers to close before notifying the services about the closing events. That is why we couldn't rely on the services to do a clean close of the SharedWorkers
.
With all the suggestions for using kill -9, please be aware that kill -9 does not shut down the Wakanda server in a gently manner.
We use it for several years now and shutting the server down this way still causes data corruption in some cases. Especially when you have shared workers working with the database in the background. Wakanda does not cleanly stop the workers.
Our current solution to minimize the problem is: 1. Sent a REST-request to Wakanda to stop the workers (you have to write your own server side method for this). This will still won't shutdown the processes in all cases! 2. Trying to kill the server without -9 parameter (up to three times) 3. If the Wakanda server is still alive, use kill -9
Btw. we asked for this a long time ago. Some reliable commandline tool like: rcwakanda start/stop/restart similar to other services like apache would be helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With