My goal is to deploy zero downtime for the ecommerce app, and I'm probably trying to do it best.
I am doing this on a nginx / unicorn / django setup as well as on nginx / unicorn / rails setup for a different server.
My strategy is preload_app = true
in my guincorn.py
/ unicorn.rb
file, then PID on server Reload and send a USR2 signal to run. It works as a process and it is of children and can pick a pre_fork
/ before_fork
and send later QUIT signal
# ... pidfile = '/ opt / run / my-website / my-website' pid '# socket quotid bind =' unix: / opt / run / my-website / my-website. Socket '# works but I would prefer socket for security # bind =' localhost: 8333 '# ... def pre_fork (server, worker): old_path_file =' / opt / run / my-website / my-website .pid.oldbin 'if os.path.isfile (old_pid_file): with open (old_pid_file,' R ') as pid_contents: try: Old_pid = int (pid_contents.read ()) if old_pid! = Server.pid: os.kill (old_pid, signal.SIGQUIT) Mistake except for exception: pass pre_fork = pre_fork
And here is a selection from my sysv script which reloads:
DESC = "My website" SITE_PATH = "/ opt / python / my-website" ENV_PATH = "/ Opt / env / my-website" RUN_AS = "myuser" settings = "my. Settings "STDOUT_LOG =" / var / log / my-webs ITE / my-website-access.log "STDERR_LOG =" / var / log / my-website / my-website-error.log "guncorn =" / op / and / My-website / bin / gunicorn.py "CMD =" $ ENV_PATH / bin / python $ SITE_PATH / manage.py run_gunicorn -c $ goncoron> gt; $ STDOUT_LOG 2 & gt; $ STDERR_LOG "sig () { Test- "$ PID" & amp; Amp; & Amp; Hit - $ 1` cat $ PID`} (if {"$ (id -un)" = "$ RUN_AS"]; Then 1 $ SE-C "$ 1" - $ RUN_AS Reload the file () eval {echo "$ DESC reload" USR2 & amp; Amp; Echo reloaded Oko & amp; Exit 0 Echo & gt; & Amp; 2 "could not be reloaded" Action "$ CMD"} "instead of" $ DESC "action in reload case =" $ 1 ";);; Esac
I chose preload_app = true for zero-downtime appeals, as the labels are loaded into app memory, even so long as I change the processes correctly It should emulate zero downtime results. Anyway it is thinking.
This works I am listening through a port but I am unable to work on it socket.
My questions are as follows:
- How is it that you are doing all this?
- Is there any better way, for example with HPP? I understand that you can not use
preload_app = true though with HPUP.
- Is it possible to use a socket? My socket is going on the quit and never coming back. My thinking is that the socket is more secure because you have access to the file system.
- Is someone doing this with
upstart
instead ofsysv
? I ideally want to do this and I saw PID coming up. This is a challenge with upper endeavor because once the performance of Gnichorn / Unicorn is done, the upstart is no longer monitoring the process that was originally managing it and to restore it somehow the wanted.
You should see your colleagues on GDS, which will be especially useful to manage it. Designed for:
Unicorn header is a utility, designed to help with the use of upstream and similar supervisors with Eutronic.
No comments:
Post a Comment