allow user to 1-command to run server

This commit is contained in:
Marvin Zhang
2019-06-01 16:55:44 +08:00
parent f2bba05421
commit e6310a2ae6
8 changed files with 81 additions and 3 deletions

View File

@@ -1,3 +1,7 @@
# 0.2.3 (unreleased)
### Features / Enhancement
- **CLI**. Allow user to use command-line interface to execute Crawlab programs.
# 0.2.2 (2019-05-30)
### Features / Enhancement
- **Automatic Extract Fields**: Automatically extracting data fields in list pages for configurable spider.

View File

@@ -1,7 +1,7 @@
# Crawlab
![](http://114.67.75.98:8081/buildStatus/icon?job=crawlab%2Fdevelop)
![](https://img.shields.io/badge/版本-v0.2.1-blue.svg)
![](https://img.shields.io/badge/版本-v0.2.3-blue.svg)
<a href="https://github.com/tikazyq/crawlab/blob/master/LICENSE" target="_blank">
<img src="https://img.shields.io/badge/License-BSD-blue.svg">
</a>

View File

@@ -1,7 +1,7 @@
# Crawlab
![](http://114.67.75.98:8081/buildStatus/icon?job=crawlab%2Fdevelop)
![](https://img.shields.io/badge/version-v0.2.1-blue.svg)
![](https://img.shields.io/badge/version-v0.2.3-blue.svg)
<a href="https://github.com/tikazyq/crawlab/blob/master/LICENSE" target="_blank">
<img src="https://img.shields.io/badge/license-BSD-blue.svg">
</a>

0
crawlab/__init__.py Normal file
View File

74
crawlab/manage.py Normal file
View File

@@ -0,0 +1,74 @@
import argparse
import os
import subprocess
from multiprocessing import Process
import sys
BASE_DIR = os.path.dirname(__file__)
APP_DESC = """
Crawlab CLI tool.
"""
ACTION_LIST = [
'serve',
'app',
'worker',
'flower',
'frontend',
]
if len(sys.argv) == 1:
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.communicate()
def run_flower():
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'flower.py')])
p.communicate()
def run_worker():
p = subprocess.Popen([sys.executable, os.path.join(BASE_DIR, 'worker.py')])
p.communicate()
def run_frontend():
p = subprocess.Popen(['npm', 'run', 'serve'],
cwd=os.path.abspath(os.path.join(BASE_DIR, '..', 'frontend')))
p.communicate()
def main():
p_app = Process(target=run_app)
p_flower = Process(target=run_flower)
p_worker = Process(target=run_worker)
p_frontend = Process(target=run_frontend)
if args.action == 'serve':
p_app.start()
p_flower.start()
p_worker.start()
p_frontend.start()
elif args.action == 'app':
p_app.start()
p_flower.start()
elif args.action == 'worker':
p_app.start()
p_worker.start()
elif args.action == 'flower':
p_flower.start()
elif args.action == 'frontend':
p_frontend.start()
else:
print(f'Invalid action: {args.action}')
if __name__ == '__main__':
main()

View File

@@ -1,6 +1,6 @@
{
"name": "crawlab",
"version": "0.2.1",
"version": "0.2.3",
"private": true,
"scripts": {
"serve": "cross-env NODE_ENV=development vue-cli-service serve --ip=0.0.0.0",