Half a personal memo or a draft of a blog. Supervisord is famous when it comes to process management of applications in the python area. While reading the gunicorn docs, I found a similar tool called gaffer, so I tried using it with fabric.
$ pip install gaffer
Easy.
If you've ever messed with heroku, I'm sure it will come to you. You can make the specified behavior by putting something called Procfile in the project and reading it. When running with gunicorn, it looks like this
gunicorn: gunicorn main:app -c gunicorn.conf.py
If you want to try it for the time being, $ gaffer start
will read the Procfile in the same directory and execute the contents.
If you want to make it a daemon, execute $ gaffer load
to make Procfile a daemon.
It will be sent to gafferd.
At this time, if gafferd is not started in the daemon state, ConnectError will be returned. Make sure gafferd --daemon runs when the OS boots. (I got stuck here for an hour)
What is it called cooperation? For the time being, you can deploy with the following.
fabfile.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from fabric.api import local, run, env, cd, hosts
CODE_DIR = "/your/Direct/Li"
env.user = "username"
@hosts('localhost:5959')
def commit():
message = raw_input("Enter a git commit message: ")
local("git add . && git commit -m \" %s \"" % message)
local("git push github master")
@hosts('server')
def deploy():
with cd(CODE_DIR):
run("git pull origin master")
#Reload
run("gaffer unload")
run("gaffer load")
I'm going to verify it while thinking that I don't have to unload it one by one.
Recommended Posts