added manage.py for CLI tool

This commit is contained in:
Marvin Zhang
2019-06-01 17:05:46 +08:00
parent e6310a2ae6
commit eef33af8fc
5 changed files with 57 additions and 35 deletions

View File

@@ -37,20 +37,7 @@ npm install
## 快速开始
```bash
# 启动后端API
python app.py
# 启动Flower服务
python ./bin/run_flower.py
# 启动worker
python ./bin/run_worker.py
```
```bash
# 运行前端
cd frontend
npm run serve
python manage.py serve
```
## 截图

View File

@@ -12,7 +12,6 @@ Celery-based web crawler admin platform for managing distributed web spiders reg
[Demo](http://114.67.75.98:8080) | [Documentation](https://tikazyq.github.io/crawlab)
## Pre-requisite
- Python 3.6+
- Node.js 8.12+
@@ -38,20 +37,7 @@ Please edit configuration file `config.py` to configure api and database connect
## Quick Start
```bash
# Start backend API
python app.py
# Start Flower service
python ./bin/run_flower.py
# Start worker
python ./bin/run_worker.py
```
```bash
# run frontend client
cd frontend
npm run serve
python manage.py serve
```
## Screenshot

View File

@@ -8,6 +8,15 @@ BASE_DIR = os.path.dirname(__file__)
APP_DESC = """
Crawlab CLI tool.
usage: python manage.py [action]
action:
serve: start all necessary services to run crawlab. This is for quick start, please checkout Deployment guide for production environment.
app: start app + flower services, normally run on master node.
worker: start app + worker services, normally run on worker nodes.
flower: start flower service only.
frontend: start frontend/client service only.
"""
ACTION_LIST = [
'serve',
@@ -17,32 +26,31 @@ ACTION_LIST = [
'frontend',
]
if len(sys.argv) == 1:
print(APP_DESC)
sys.argv.append('--help')
parser = argparse.ArgumentParser()
parser.add_argument('action', type=str)
# parser.add_argument('-q', '--quality', type=int, default=0,
# help="download video quality : 1 for the standard-definition; 3 for the super-definition")
args = parser.parse_args()
def run_app():
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'app.py')])
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'crawlab', 'app.py')])
p.communicate()
def run_flower():
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'flower.py')])
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'crawlab', 'flower.py')])
p.communicate()
def run_worker():
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'worker.py')])
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'crawlab', 'worker.py')])
p.communicate()
def run_frontend():
p = subprocess.Popen(['npm', 'run', 'serve'],
cwd=os.path.abspath(os.path.join(BASE_DIR, '..', 'frontend')))
cwd=os.path.abspath(os.path.join(BASE_DIR, 'frontend')))
p.communicate()

2
setup.cfg Normal file
View File

@@ -0,0 +1,2 @@
[metadata]
description-file = README.md

39
setup.py Normal file
View File

@@ -0,0 +1,39 @@
#-*- encoding: UTF-8 -*-
from setuptools import setup, find_packages
VERSION = '0.2.3'
with open('README.md') as fp:
readme = fp.read()
setup(name='crawlab-server',
version=VERSION,
description="Celery-based web crawler admin platform for managing distributed web spiders regardless of languages and frameworks.",
long_description=readme,
classifiers=['Python', 'Javascript', 'Scrapy'], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='python crawlab celery crawler spider platform scrapy',
author='tikazyq',
author_email='tikazyq@163.com',
url='https://github.com/tikazyq/crawlab',
license='BSD',
packages=find_packages(),
include_package_data=True,
zip_safe=True,
install_requires=[
'celery',
'flower',
'requests',
'pymongo',
'flask',
'flask_cors',
'flask_restful',
'lxml',
'gevent',
'scrapy',
],
entry_points={
'console_scripts':[
'crawlab = crawlab.manage:main'
]
},
)