1
|
sudo
apt-get
install
git
|
1
2
3
4
5
6
7
8
9
10
11
|
drwxrwxr-x 6 xpleaf xpleaf 4096 1月 29 16:04 .
drwxr-xr-x 38 xpleaf xpleaf 4096 1月 29 16:01 ..
drwxrwxr-x 7 xpleaf xpleaf 4096 1月 29 03:31 app
-rw-rw-r-- 1 xpleaf xpleaf 3295 1月 29 03:31 config.py
-rw-rw-r-- 1 xpleaf xpleaf 1083 1月 29 03:31 LICENSE
-rwxrwxr-x 1 xpleaf xpleaf 2391 1月 29 03:31 manage.py
drwxrwxr-x 3 xpleaf xpleaf 4096 1月 29 03:31 migrations
-rw-rw-r-- 1 xpleaf xpleaf 25 1月 29 03:13 Procfile
-rw-rw-r-- 1 xpleaf xpleaf 376 1月 29 03:31 README.md
-rw-rw-r-- 1 xpleaf xpleaf 76 1月 29 03:13 requirements.txt
drwxrwxr-x 2 xpleaf xpleaf 4096 1月 29 03:31 tests
|
1
2
3
4
|
xpleaf@leaf:~
/Heroku_pro
$
pwd
/home/xpleaf/Heroku_pro
xpleaf@leaf:~
/Heroku_pro
$
ls
app config.py LICENSE manage.py migrations README.md requirements.txt tests Procfile
|
1
2
|
xpleaf@leaf:~
/Heroku_pro
$ git init
初始化空的 Git 版本库于
/home/xpleaf/Heroku_pro/
.git/
|
1
2
3
|
xpleaf@leaf:~
/Heroku_pro
$
ls
-a
. app .git manage.py README.md tests
.. config.py LICENSE migrations requirements
|
1
2
3
4
5
6
7
8
9
10
|
xpleaf@leaf:~/Heroku_pro$ git add .
xpleaf@leaf:~/Heroku_pro$ git commit -m
"ver1.0"
[master (根提交) a7cea3f] ver1.
0
78
files changed,
3350
insertions(+)
create mode
100644
LICENSE
create mode
100644
README.md
create mode
100644
app/__init__.py
create mode
100644
app/api_1_0/__init__.py
create mode
100644
app/api_1_0/authentication.py
......
|
1
|
wget -O- https:
//toolbelt
.heroku.com
/install-ubuntu
.sh | sh
|
1
2
3
4
5
6
|
xpleaf@leaf:~
/Heroku_pro
$ heroku login
Enter your Heroku credentials.
Email: flasky_mini@sina.com
Password (typing will be hidden):
Logged
in
as flasky_mini@sina.com
xpleaf@leaf:~
/Heroku_pro
$
|
1
2
3
|
xpleaf@leaf:~
/Heroku_pro
$ heroku create my-heroku-app-cn
Creating my-heroku-app-cn...
done
, stack is cedar-14
https:
//my-heroku-app-cn
.herokuapp.com/ | https:
//git
.heroku.com
/my-heroku-app-cn
.git
|
1
2
3
4
5
6
7
8
|
xpleaf@leaf:~
/Heroku_pro
$ heroku addons:create heroku-postgresql:hobby-dev
Creating postgresql-rectangular-17531...
done
, (
free
)
Adding postgresql-rectangular-17531 to my-heroku-app-cn...
done
Setting DATABASE_URL and restarting my-heroku-app-cn...
done
, v3
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pg:copy
Use `heroku addons:docs heroku-postgresql` to view documentation.
|
1
2
|
MAIL_USERNAME
=
os.environ.get(
'MAIL_USERNAME'
)
MAIL_PASSWORD
=
os.environ.get(
'MAIL_PASSWORD'
)
|
1
2
3
4
5
6
|
xpleaf@leaf:~
/Heroku_pro
$ heroku config:
set
MAIL_USERNAME=
"xpleaf"
Setting config vars and restarting my-heroku-app-cn...
done
MAIL_USERNAME: xpleaf
xpleaf@leaf:~
/Heroku_pro
$ heroku config:
set
MAIL_PASSWORD=
"***"
Setting config vars and restarting my-heroku-app-cn...
done
MAIL_PASSWORD: ***
|
必需文件 | 说明 |
requirements.txt | Web应用程序所依赖的各种第三方扩展包 |
Procfile | 里面包含的是我的Web应用服务器启动时执行的命令 |
1
2
3
|
xpleaf@leaf:~
/Heroku_pro
$
ls
-l requirements.txt Procfile
-rw-rw-r-- 1 xpleaf xpleaf 25 1月 29 03:13 Procfile
-rw-rw-r-- 1 xpleaf xpleaf 76 1月 29 03:13 requirements.txt
|
1
2
3
4
5
6
7
8
9
10
|
Flask==0.10.1
Flask-Bootstrap==3.0.3.1
Flask-HTTPAuth==2.7.0
Flask-Login==0.3.1
...
SQLAlchemy==0.9.9
WTForms==1.0.5
Werkzeug==0.10.4
alembic==0.6.2
bleach==1.4.0
|
1
|
web: gunicorn manage:app
|
1
2
|
git add .
git commit -m
"ver1.0"
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
xpleaf@leaf:~
/Heroku_pro
$ git push heroku master
对象计数中: 97, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (90
/90
), 完成.
写入对象中: 100% (97
/97
), 35.04 KiB | 0 bytes
/s
, 完成.
Total 97 (delta 22), reused 0 (delta 0)
remote: Compressing
source
files...
done
.
remote: Building
source
:
remote:
remote: -----> Python app detected
remote: -----> Installing runtime (python-2.7.11)
remote: -----> Installing dependencies with pip
remote: Collecting Flask==0.10.1 (from -r requirements
/common
.txt (line 1))
..........
remote: -----> Preparing static assets
remote: Collectstatic configuration error. To debug, run:
remote: $ heroku run python manage.py collectstatic --noinput
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 37.2M
remote: -----> Launching...
remote: Released v6
remote: https:
//my-heroku-app-cn
.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy....
done
.
To https:
//git
.heroku.com
/my-heroku-app-cn
.git
* [new branch] master -> master
|
1
2
3
4
5
6
7
8
9
10
11
|
#启动Web服务器进行相关初始化配置
xpleaf@leaf:~
/Heroku_pro
$ heroku run python manage.py deploy
Running python manage.py deploy on my-heroku-app-cn... up, run.7690
INFO [alembic.migration] Context impl SQLiteImpl.
......
INFO [alembic.migration] Running upgrade 288cd3dc5a8 -> 2356a38169ea, followers
INFO [alembic.migration] Running upgrade 2356a38169ea -> 51f5ccfba190, comments
#重新启动
xpleaf@leaf:~
/Heroku_pro
$ heroku restart
Restarting dynos...
done
|
1
2
3
4
5
6
7
8
9
10
11
12
|
#告诉Heroku,你要进行升级操作
heroku maintenance:on
#提交部署
git push heroku master
#重新运行服务器
heroku run python manage.py deploy
heroku restart
#告诉Heroku,升级完成
maintenance:off
|