Rapid develop framework base on Django
python3 -m pip install django-rework
# It will create project in current dir
# eg: initialize a new project named `pony`
rework init pony
rework add users
rework deploy --init
rework deploy
App | Description | docs in English | 简体中文文档 |
---|---|---|---|
users | Users system | users.md | users_cn.md |
django-rework
deal with DevOps using Fabric
. You should add hosts configurations in fabfile.py
.
import os
from rework.core.devops.hosts import loads
# The first argument `default` is host alias
# `user` is optional, default value is `root`
# `envs` is the server support deploy environments
# `exclude_components` is optional, it's been used in `fab setup_server`
loads(
'default', {
'host': 'your-server-ip',
'port': 22,
'user': 'root',
'connect_kwargs': {
'password': 'server-password',
},
'envs': ['test', 'prod'],
'exclude_components': ['redis'],
}
)
# Using SSH key
loads(
'web1', {
'host': 'your-server-ip',
'connect_kwargs': {
'key_filename': os.path.join(os.path.abspath('.'), '.deploy/private.pem'),
},
}
)
You can change host alias as you like: web1
etc.
fab -H web1 deploy
if not -H
provided, the default alias will use according the order below:
- environment name:
dev
,test
,prod
default
By default, environments is dev
, test
, prod
, every environment name is a generic fabric tasks.
# deploy to `test` environment
fab test deploy
If you want to update requirements, you should add arguments -r
or --requirements_update
fab test deploy -r
Code format using Google 的 yapf
,recommend to install yapf
globally:
# install yapf using pip in python3
$ python3 -m pip install yapf
# find and create soft link to `/usr/local/bin/yapf`
# find yapf execute file
$ which yapf
# (/usr/local/python3.7/bin/yapf) possible location
$ ln -s /usr/local/python3.7/bin/yapf /usr/local/bin/yapf