加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

基于windows使用fabric将gitlab的文件远程同步到服务器

发布时间:2020-12-14 02:37:07 所属栏目:Windows 来源:网络整理
导读:觉得django项目从本地更新push到gitlab,再执行fabric脚本从gitlab更新服务器项目挺方便的,当然从本地直接到服务器就比较灵活。 # -*- coding: utf-8 -*-from fabric.api import env,runfrom fabric.operations import sudoGIT_REPO = "gitlab-project地址"

觉得django项目从本地更新push到gitlab,再执行fabric脚本从gitlab更新服务器项目挺方便的,当然从本地直接到服务器就比较灵活。

# -*- coding: utf-8 -*-
from fabric.api import env,run
from fabric.operations import sudo

GIT_REPO = "gitlab-project地址"
env.user = ‘服务器用户名‘
env.password = ‘服务器用户密码‘
env.hosts = [‘服务器ip‘]
env.port = ‘22‘

def deploy():
    source_folder = ‘服务器项目目录‘    # 预先把初始项目包含git拷进去
    # 执行保留服务器settings配置的pull操作同步gitlab更新到服务器
    run(‘cd %s &&  git stash && git pull && git stash pop‘ % source_folder)
    run("""
        cd {} &&
        pip install -r requirements.txt &&
        python manage.py collectstatic --noinput &&
        python manage.py migrate
        """.format(source_folder))
    sudo(‘supervisorctl restart project_name‘)

    

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读