Giter Club home page Giter Club logo

nut's Introduction

The Django framework

概览

果库网站 V4

系统环境

  • Ubuntu
  • Python2.7
  • MySQL
  • Nginx
  • Redis

安装 MySQL

brew install mysql

安装 ImageMagick

brew install imagemagick

快速安装

virtualenv guoku-v4
source /path/to/guoku-v4/bin/active
pip install -r requirements

后端框架

前端框架

安装包

分词

pip install jieba

Debug 工具

部署到服务器

  • deploy 目录结构
deploy/
├── config.ini
├── guoku.pass
├── reload_server.py
├── update_online_code.sh
└── upload_code.py
  • config.ini 配置文件
  • guoku.pass 密码文件
  • reload_server.py 重启服务
  • upload_code.py 上传代码
  • update_online_code.sh 更新代码 并且重启服务
pip install fabric
cd deployo/
fab -f upload_static.py deploy_static
fab -f upload_code.py uploac_code

Models 与 Cache 之间的关系

* 以获取热门商品为例:

利用 django models queryset 实现扩展的 SQL 查询。 Manager 方法来实现缓存。 以减少 models 层面的改动,而影响 views.

class EntityLikeQuerySet(models.query.QuerySet):

    def popular(self):
        dt = datetime.now()
        days = timedelta(days=7)
        popular_time = (dt - days).strftime("%Y-%m-%d") + ' 00:00'
        return self.filter(created_time__gt=popular_time).annotate(dcount=models.Count('entity')).values_list('entity_id', flat=True)

    def user_like_list(self, user, entity_list):

        return self.filter(entity_id__in=entity_list, user=user).values_list('entity_id', flat=True)


class EntityLikeManager(models.Manager):

    def get_query_set(self):
        return EntityLikeQuerySet(self.model, using=self._db)

    def popular(self):
        res = cache.get('entity_popular')
        if res:
            return res
        res = self.get_query_set().popular()
        cache.set('entity_popular', res, timeout=3600)
        return res

    def user_like_list(self, user, entity_list):

        return self.get_query_set().user_like_list(user=user, entity_list=entity_list)

导出数据

/opt/mysql5/bin/mysqldump --single-transaction --flush-logs -u root core --ignore-table=core.core_entity_like --ignore-table=core.notifications_notification > core.sql

发布服务器

  • 使用 keepalived 健康性检查
  • 10.0.2.49 (master)
  • 10.0.2.46 (backup)

application server

  • 10.0.2.46
  • 10.0.2.47

数据缓存服务

  • 10.0.2.46
  • 10.0.2.120
  • 10.0.2.115

图片处理服务器 相关代码

  • 10.0.2.110
  • 10.0.2.115

图片缓存服务器

  • 10.0.2.110
  • 10.0.2.115

图片存储服务器

  • 10.0.2.50 (tracker)
  • 10.0.2.48
  • 10.0.2.125
  • 10.0.2.200

数据库服务器

  • 10.0.2.90 (master)
  • 10.0.2.95 (slave) read only

solr 服务器

  • solr 主要运行在 docker 容器中
  • 10.0.2.115
  • 10.0.2.110 (backup)

消息队列服务器

  • 10.0.2.125 (rabbitmq)

Email

[email protected]

nut's People

Contributors

edison7500 avatar azureray avatar goalong avatar martinsmjc avatar laohanmsa avatar buting2015 avatar huiter avatar sontek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.