[PYTHON] Easy deployment environment with gaffer + fabric

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.

Installation

$ pip install gaffer

Easy.

Procfile can be used

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

I will try using it for the time being

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)

Works with fabric

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

Easy deployment environment with gaffer + fabric
Easy tox environment with Jenkins
Make your Python environment "easy" with VS Code
Easy Grad-CAM with pytorch-gradcam
From Kafka to KSQL --Easy environment construction with docker
Create a python development environment with vagrant + ansible + fabric
Python environment with docker-compose
Easy debugging with ipdb
Virtual environment with Python 3.6
Easy TopView with OpenCV
Easy web server construction & deployment with EB CLI + git + Django
From environment construction to deployment for flask + Heroku with Docker
Building a pyhon environment without using Anaconda (with easy startup)
First Fabric (Python deployment tool)
Create an environment with virtualenv
[Co-occurrence analysis] Easy co-occurrence analysis with Python! [Python]
Minimal website environment with django
Install Python environment with Anaconda
Manage python environment with virtualenv
Fast file transfer with fabric
Easy folder synchronization with Python
Build python3 environment with ubuntu 16.04
ML environment construction with Miniconda
Easy image classification with TensorFlow
Prepare python3 environment with Docker
Build python environment with direnv
Easy Python compilation with NUITKA-Utilities
Easy HTTP server with Python
Easy proxy login with django-hijack
Switch virtual environment with jupyter
Set environment variables with lambda-uploader
Do multi-stage SSH with Fabric
I tried standalone deployment of play with fabric [AWS operation with boto] [Play deployment]