OtherWriting an rc script for gunicorn & django

Active Member

I'm looking to deploy a Django application onto a FreeBSD 11.1 server, I've read a number of articles about using www/py36-gunicorn to provide the communications between www/nginx and Django, and brief trials appear successful.

I'm now looking to make a service that I can service myapp start, and have come up and down with the FreeBSD host.

It's the beginnings of a script that is part from the Practical rc.d scripting in BSD, and part "getting it to work enough in practise". I know I need to create some variables to allow values to be read from rc.conf.

I'm not sure how to stop a service running with daemon(8), so have put something together, however it doesn't look "proper" to me. Is it anywhere near correct? Or is there a better way?

Is the whole script just awful and generally is there a better way to do this?

Is the a better resource to read about writing service scripts? The article appears somewhat dated and limited, and there are lots of articles I've come across on the web which seem even less knowledgeable.

Administrator

2) Just send a kill(1) to the PID of the process. Unless your application has a specific command to shutdown, then you should use that. There's no need to clean up the PID file yourself, daemon(8) already takes care of this.

Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.