项目管理系统 TAIGA 部署

摘要:
GET还掌握了Django部署的一些技巧。因此,如果您只使用nginx静态部署,那么需要解决的关键问题是后端部署。幸运的是,上面给出的安装指南的链接提供了一个详细且实用的部署过程。事实上,根据指南进行安装没有任何障碍,因此您需要查看日志以查找问题。pip的两个命令将对应于未来系统中的3.4版本。在这个过程中,我们学到了具体的逻辑。

题记

使用了 MantisBT 一段时间,觉得功能太少,只局限在错误跟踪,而且操作体验比较差,界面很糟糕,很早就想将其换掉。

偶然发现一个很不错的新选择:Taiga,于是就试着将其部署下来,发现绝对是一个好东西,对于实践 Scrum 项目管理方法的,更是不可多得的利器!

产品官网:https://taiga.io/

GITHUB:https://github.com/taigaio

安装指南:http://taigaio.github.io/taiga-doc/dist/setup-production.html

由于这个项目是用 Django(1.7) 开发的,因此个人情感非常认同,并且在部署的过程中,也顺手牵羊 GET 到了关于 Django 部署的一些技能。

1. 部署概要

首先,项目是使用 RESTFUL 模式开发的,也就是说,后台跟前台完全独立。

前台部分,使用的是 AngularJS (也非常对我的口味),因此单纯使用 nginx 静态部署,不存在太大的问题。

关键是后端,使用 Django + REST Framework,因此部署起来总是有那么点困惑,下面重点需要解决的是后端部署的问题。

不过好在前面给出的安装指南链接上面给出了详尽可用叹为观止的部署流程,虽然步骤较多,但是也是一步一步搞下来就可以使用了,下面就根据这个流程过一遍,并且对未尽部分,一些可能卡住的情况进行一下说明,兼做记录。

其实按照指南装下来基本没什么障碍,主要问题在于,有些 PyPI 的包其实在 requirements.txt 里面是没有的,因此需要看日志发现问题,然后手动补上这些包。


2. 环境准备

http://taigaio.github.io/taiga-doc/dist/setup-production.html#_before_starting

首先,我们的环境基本跟指引里面的一致,使用 Ubuntu14.04,对一下其他条件:

  1. IP 没什么好说的
  2. 主机名,我们用的是 taiga.easecloud.cn,注意把后面的 example.com 换成我们自己的即可。
  3. 用户 taiga,这个我们需要事先创建好,并且赋予其 sudo 权限。
  4. system ram 请无视。

现在创建 taiga 用户:

adduser taiga

然后赋予其 sudo 权限:

visudo
# User privilege specification
root    ALL=(ALL:ALL) ALL
# 在这行后面加上:
taiga    ALL=(ALL:ALL) ALL

3. 后台安装:

3.1. 安装依赖项

sudo apt-get install -y build-essential binutils-doc autoconf flex bison libjpeg-dev
sudo apt-get install -y libfreetype6-dev zlib1g-dev libzmq3-dev libgdbm-dev libncurses5-dev
sudo apt-get install -y automake libtool libffi-dev curl git tmux

3.2. 安装 postgresql

sudo apt-get install -y postgresql-9.3 postgresql-contrib-9.3
sudo apt-get install -y postgresql-doc-9.3 postgresql-server-dev-9.3
# 创建数据库
sudo -u postgres createuser taiga
sudo -u postgres createdb taiga -O taiga

3.3. 安装 python 环境

sudo apt-get install -y python3 python3-pip python-dev python3-dev python-pip virtualenvwrapper
sudo apt-get install libxml2-dev libxslt-dev

这里安装了 Python3.4 作为主要的 python 环境,也就是说 python, pip 这两个命令日后在系统里面对应 3.4 版本,而 python2 和 pip2 对应旧版的 2.7 版本。

另有值得注意的是 virtualenv 的安装,后面用到这个配置相当重要,具体逻辑在过程中进行了学习,参考:

http://www.huangwenchao.com.cn/2015/05/python-virtualenv.html

下载源码
cd ~
git clone https://github.com/taigaio/taiga-back.git taiga-back
cd taiga-back
git checkout stable
创建 virtualenv taiga
mkvirtualenv -p /usr/bin/python3.4 taiga
安装 PyPI 依赖项
pip install -r requirements.txt

注意!在实际操作中这里的依赖项不全,因此如果跑步起来需要看日志看一下少了哪个库。

映射数据库和载入初始数据
python manage.py migrate --noinput
python manage.py loaddata initial_user
python manage.py loaddata initial_project_templates
python manage.py loaddata initial_role
python manage.py collectstatic --noinput

注意第一步很容易卡住,原因是缺少 PyPI 库的问题,关注日志。

填写 Python 配置文件
from .common import *

MEDIA_URL = "http://example.com/media/"
STATIC_URL = "http://example.com/static/"
ADMIN_MEDIA_PREFIX = "http://example.com/static/admin/"
SITES["front"]["scheme"] = "http"
SITES["front"]["domain"] = "example.com"

SECRET_KEY = "theveryultratopsecretkey"

DEBUG = False
TEMPLATE_DEBUG = False
PUBLIC_REGISTER_ENABLED = True

DEFAULT_FROM_EMAIL = "no-reply@example.com"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

# Uncomment and populate with proper connection parameters
# for enable email sending.
#EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
#EMAIL_USE_TLS = False
#EMAIL_HOST = "localhost"
#EMAIL_HOST_USER = ""
#EMAIL_HOST_PASSWORD = ""
#EMAIL_PORT = 25

# Uncomment and populate with proper connection parameters
# for enable github login/singin.
#GITHUB_API_CLIENT_ID = "yourgithubclientid"
#GITHUB_API_CLIENT_SECRET = "yourgithubclientsecret"

注意把上面的域名换掉就差不多了,发送邮件的尚未调试。

3.4. 安装验证

在 ~/taiga-back/ 下面执行:

workon taiga
python manage.py runserver 0.0.0.0:8111

好了之后,可以通过 http://example.com:8111/api/v1/ 访问接口,用户名 admin 密码 123123 登录正常即说明安装正确。

3.5. 异步任务

(非必须)跳过

4. 前端部署

由于是静态页面,部署比较简单,基本无意外。

下载代码
cd ~
git clone https://github.com/taigaio/taiga-front-dist.git taiga-front-dist
cd taiga-front-dist
git checkout stable
编辑配置 ~/taiga-front-dist/dist/js/conf.json
{
    "api": "http://example.com/api/v1/",
    "eventsUrl": "ws://example.com/events",
    "debug": "true",
    "publicRegisterEnabled": true,
    "feedbackEnabled": true,
    "privacyPolicyUrl": null,
    "termsOfServiceUrl": null,
    "maxUploadFileSize": null,
    "contribPlugins": []
}

然后把 nginx 的虚拟主机配置到这个目录下即可运转。

5. 事件安装

(非必须)跳过

6. 最终章(HTTP 和 WSGI 部署)

我们使用 Circus 做进程守护,Gunicorn 做 WSGI 容器,然后通过 Nginx 对外提供 HTTP 服务。

6.1. Circus 和 Gunicorn

安装部件,注意 Circus 需要使用 pip2 安装。

sudo pip2 install circus
Circus 基础配置 ~/circus.ini

按照原版配置基本无需修改,可以将 circus.ini 放到其他目录,我自己的实践中放到了 /var/www/circus.ini 中。

[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
statsd = true

[watcher:taiga]
working_dir = /home/taiga/taiga-back
cmd = gunicorn
args = -w 3 -t 60 --pythonpath=. -b 127.0.0.1:8001 taiga.wsgi
uid = taiga
numprocesses = 1
autostart = true
send_hup = true
stdout_stream.class = FileStream
stdout_stream.filename = /home/taiga/logs/gunicorn.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /home/taiga/logs/gunicorn.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4

[env:taiga]
PATH = /home/taiga/.virtualenvs/taiga/bin:$PATH
TERM=rxvt-256color
SHELL=/bin/bash
USER=taiga
LANG=en_US.UTF-8
HOME=/home/taiga
PYTHONPATH=/home/taiga/.virtualenvs/taiga/lib/python3.4/site-packages

注意上面有一点特别容易卡住,就是输出的日志文件所在目录 /home/taiga/logs/ 必须存在!否则会启动失败,引起需要确保日志目录事先创建好。

修改 Circus 的启动设置

配置文件在:/etc/init/circus.conf

start on filesystem and net-device-up IFACE=lo
stop on runlevel [016]

respawn
exec /usr/local/bin/circusd /home/taiga/circus.ini

注意 circus.ini 的路径如果不在这个地方需要对应修改。

然后就可以启动服务了。

sudo service circus start

6.2. Nginx

安装 Nginx
sudo apt-get install -y nginx
添加虚拟主机

创建虚拟主机配置文件:/etc/nginx/sites-available/taiga

server {
    listen 80 default_server;
    server_name _;

    large_client_header_buffers 4 32k;
    client_max_body_size 50M;
    charset utf-8;

    access_log /home/taiga/logs/nginx.access.log;
    error_log /home/taiga/logs/nginx.error.log;

    # Frontend
    location / {
        root /home/taiga/taiga-front-dist/dist/;
        try_files $uri $uri/ /index.html;
    }

    # Backend
    location /api {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8001/api;
        proxy_redirect off;
    }

    # Django admin access (/admin/)
    location /admin {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8001$request_uri;
        proxy_redirect off;
    }

    # Static files
    location /static {
        alias /home/taiga/taiga-back/static;
    }

    # Media files
    location /media {
        alias /home/taiga/taiga-back/media;
    }
}

注意里面的 default_server 和 server_name 如果在需要独立配置虚拟主机而不是直接占用全站资源,需要根据实际修改(删除 default-server,把 server_name) 改成自己的。

然后将其启用:

sudo ln -s /etc/nginx/sites-available/taiga /etc/nginx/sites-enabled/taiga

6.2.1. 启用 HTTPS

(非必须)跳过


(完)


【转载请附】愿以此功德,回向 >>

原文链接:http://www.huangwenchao.com.cn/2015/05/taiga-deployment.html【项目管理系统 Taiga 部署手札】

免责声明:文章转载自《项目管理系统 TAIGA 部署》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Windows下MongoDB常用命令C# DotNetZip压缩单、多文件以及文件夹下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

非对称加密----加解密和数字签名

一、对称加密 对称加密:加密和解密使用相同密钥的加密算法。 对称加密的特点: 1)、速度快,通常在消息发送方需要加密大量数据时使用。 2)、密钥是控制加密及解密过程的指令。 3)、算法是一组规则,规定如何进行加密和解密。 典型应用场景:离线的大量数据加密(用于存储的) 常用的加密算法:DES、3DES、AES、TDEA、Blowfifish、RC2、RC...

学习c++ (五) dll注入和卸载

在学习第一篇时,就直接折腾代码,这是我学习的方法,基础的只是简单过一遍就好了,因为根本记得不够深刻,还是用了之后,才知道真正的含义。 然后在第一篇的基础上,把卸载加进来了,同时重整理了注入的代码,更重要的是这次的消息接收,抛弃了MFC,直接用的C++写的,感觉真好 另外,在这个注入和进程的通讯上,还遇到两个问题: 第一点,对于OpenProcess 时使用...

luffy(一)

一.pip安装源 介绍 """1、采用国内源,加速下载模块的速度2、常用pip源: -- 豆瓣:https://pypi.douban.com/simple -- 阿里:https://mirrors.aliyun.com/pypi/simple3、加速安装的命令: -- >: pip install -i https://pypi....

拉普拉斯平滑(Laplace Smoothing)

拉普拉斯平滑(Laplace Smoothing)又称 加1平滑,常用平滑方法。解决零概率问题。 背景:为什么要做平滑处理? 零概率问题:在计算实例的概率时,如果某个量x,在观察样本库(训练集)中没有出现过,会导致整个实例的概率结果是0。 在文本分类的问题中,当一个词语没有在训练样本中出现,该词语调概率为0,使用连乘计算文本出现概率时也为0。 这是不合理的...

bootstrap 导航栏、输入框按钮组、栅格系统

栅格系统 文档地址:http://v3.bootcss.com/css/#grid 栅格系统的强大之处在于灵活的处理不同分辨率下的页面布局,对于我这种理科思维并且是前端弱鸡的人来说,优点在于可预见、可控,同时最大限度的减少了页面布局过程中的代码量,实乃神器。 举例说明: <div class="container-fluid">...

【转】WPF自定义控件与样式(8)-ComboBox与自定义多选控件MultComboBox

一.前言   申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等。   本文主要内容: 下拉选择控件ComboBox的自定义样式及扩展; 自定义多选控件MultiComboBox; 二.下拉选择控件ComboBox的自定义样式及扩展 2.1基本样式   先看看基础效果图:     从功能上ComboBo...