-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_manager.py
81 lines (62 loc) · 1.78 KB
/
app_manager.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
# python imports
import os
# flask imports
from flask.ext.script import Manager
# project imports
from project import app
from project.application import configure_app
from project.config import DevelopmentConfig, DeploymentConfig, TestingConfig
manager = Manager(app)
@manager.command
def run():
"""
Run server on port 8080 with default config.
"""
app.run(host='0.0.0.0', port=8080)
@manager.command
def develop():
"""
Run server on port 8080 with development config.
"""
configure_app(app, DevelopmentConfig)
app.run(host='0.0.0.0', port=8080)
@manager.command
def deploy():
"""
Run server on port 8080 with deployment config.
"""
configure_app(app, DeploymentConfig)
app.run(host='0.0.0.0', port=8080)
@manager.command
def testing():
"""
Run server on port 8080 with testing config.
"""
configure_app(app, TestingConfig)
app.run(host='0.0.0.0', port=8080)
@manager.option(dest='config_file')
def custom_config(config_file):
"""
Run server on port 8080 with custom config file.
"""
configure_app(app, os.path.abspath(config_file), is_pyfile=True)
app.run(host='0.0.0.0', port=8080)
@manager.command
def celery():
"""
Run celery worker.
"""
from project.extensions import celery
from celery.bin import worker
worker = worker.worker(app=celery)
worker.run()
@manager.option('-r', dest='resource', required=False, help='Resource name')
@manager.option('-u', dest='url', required=False, default='http://localhost:8080', help='Server url')
def test(resource, url):
"""
Test api. You can specify a resource (like api_1.user) for single testing.
By default all resources will be tested.
"""
from tests import run
run(url, resource)