├── .gitignore ├── LICENSE ├── README.md ├── backend ├── backend │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── cetus │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── func.py │ ├── models.py │ ├── serializers.py │ ├── tasks.py │ ├── tests.py │ └── views.py ├── install │ ├── docker-compose.yml │ └── mysql │ │ └── my.cnf ├── manage.py ├── requirement.txt ├── shells │ ├── catalog_cetus.py │ ├── cetus_monitor.py │ ├── check_cetus.py │ ├── download_cetus.py │ ├── install_cetus.py │ └── operate_cetus.py └── uwsgi.cnf ├── deploy.sh ├── frontend ├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .postcssrc.js ├── .travis.yml ├── build │ ├── build.js │ ├── check-versions.js │ ├── logo.png │ ├── utils.js │ ├── vue-loader.conf.js │ ├── webpack.base.conf.js │ ├── webpack.dev.conf.js │ └── webpack.prod.conf.js ├── config │ ├── dev.env.js │ ├── index.js │ └── prod.env.js ├── docs │ ├── HELP.md │ ├── img │ │ ├── cetus_command.png │ │ ├── cetus_config.png │ │ ├── cetus_fund_params.png │ │ ├── cetus_info.png │ │ ├── cetus_install.png │ │ ├── cetus_list.png │ │ ├── cetus_monitor.png │ │ ├── cetus_task.png │ │ ├── cetus_user.png │ │ └── cetus_vdb.png │ └── lededba.png ├── favicon.ico ├── index.html ├── package.json ├── src │ ├── App.vue │ ├── api │ │ ├── cetus.js │ │ └── login.js │ ├── components │ │ ├── Breadcrumb │ │ │ └── index.vue │ │ ├── Hamburger │ │ │ └── index.vue │ │ └── SvgIcon │ │ │ └── index.vue │ ├── icons │ │ ├── index.js │ │ └── svg │ │ │ ├── 404.svg │ │ │ ├── bug.svg │ │ │ ├── chart.svg │ │ │ ├── clipboard.svg │ │ │ ├── component.svg │ │ │ ├── dashboard.svg │ │ │ ├── documentation.svg │ │ │ ├── drag.svg │ │ │ ├── email.svg │ │ │ ├── example.svg │ │ │ ├── excel.svg │ │ │ ├── eye.svg │ │ │ ├── form.svg │ │ │ ├── icon.svg │ │ │ ├── international.svg │ │ │ ├── language.svg │ │ │ ├── link.svg │ │ │ ├── lock.svg │ │ │ ├── message.svg │ │ │ ├── money.svg │ │ │ ├── password.svg │ │ │ ├── people.svg │ │ │ ├── peoples.svg │ │ │ ├── qq.svg │ │ │ ├── shoppingCard.svg │ │ │ ├── star.svg │ │ │ ├── tab.svg │ │ │ ├── table.svg │ │ │ ├── theme.svg │ │ │ ├── user.svg │ │ │ ├── wechat.svg │ │ │ └── zip.svg │ ├── main.js │ ├── permission.js │ ├── router │ │ └── index.js │ ├── store │ │ ├── getters.js │ │ ├── index.js │ │ └── modules │ │ │ ├── app.js │ │ │ └── user.js │ ├── styles │ │ ├── element-ui.scss │ │ ├── index.scss │ │ ├── mixin.scss │ │ ├── sidebar.scss │ │ ├── transition.scss │ │ └── variables.scss │ ├── utils │ │ ├── auth.js │ │ ├── index.js │ │ ├── request.js │ │ └── validate.js │ └── views │ │ ├── 404.vue │ │ ├── docs │ │ └── index.vue │ │ ├── form │ │ ├── index.vue │ │ └── tasks.vue │ │ ├── item │ │ ├── chart.vue │ │ ├── command.vue │ │ ├── config.vue │ │ ├── index.vue │ │ ├── info.vue │ │ └── monitor.vue │ │ ├── layout │ │ ├── Layout.vue │ │ ├── components │ │ │ ├── AppMain.vue │ │ │ ├── Navbar.vue │ │ │ ├── Sidebar │ │ │ │ ├── Item.vue │ │ │ │ ├── SidebarItem.vue │ │ │ │ └── index.vue │ │ │ └── index.js │ │ └── mixin │ │ │ └── ResizeHandler.js │ │ ├── link │ │ └── index.vue │ │ ├── list │ │ └── index.vue │ │ └── login │ │ └── index.vue └── static │ ├── .gitkeep │ └── tinymce4.7.5 │ ├── langs │ └── zh_CN.js │ ├── plugins │ ├── codesample │ │ └── css │ │ │ └── prism.css │ ├── emoticons │ │ └── img │ │ │ ├── smiley-cool.gif │ │ │ ├── smiley-cry.gif │ │ │ ├── smiley-embarassed.gif │ │ │ ├── smiley-foot-in-mouth.gif │ │ │ ├── smiley-frown.gif │ │ │ ├── smiley-innocent.gif │ │ │ ├── smiley-kiss.gif │ │ │ ├── smiley-laughing.gif │ │ │ ├── smiley-money-mouth.gif │ │ │ ├── smiley-sealed.gif │ │ │ ├── smiley-smile.gif │ │ │ ├── smiley-surprised.gif │ │ │ ├── smiley-tongue-out.gif │ │ │ ├── smiley-undecided.gif │ │ │ ├── smiley-wink.gif │ │ │ └── smiley-yell.gif │ └── visualblocks │ │ └── css │ │ └── visualblocks.css │ ├── skins │ └── lightgray │ │ ├── content.inline.min.css │ │ ├── content.min.css │ │ ├── fonts │ │ ├── tinymce-mobile.woff │ │ ├── tinymce-small.eot │ │ ├── tinymce-small.svg │ │ ├── tinymce-small.ttf │ │ ├── tinymce-small.woff │ │ ├── tinymce.eot │ │ ├── tinymce.svg │ │ ├── tinymce.ttf │ │ └── tinymce.woff │ │ ├── img │ │ ├── anchor.gif │ │ ├── loader.gif │ │ ├── object.gif │ │ └── trans.gif │ │ ├── skin.min.css │ │ └── skin.min.css.map │ └── tinymce.min.js └── supervisor.cnf /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | .DS_Store 4 | migrations/ 5 | node_modules/ 6 | dist/ 7 | 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | package-lock.json 12 | *.pyc 13 | *.log 14 | *.suo 15 | *.ntvs* 16 | *.njsproj 17 | *.sln 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Mikurula 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cetus-GUI 2 | 3 | --- 4 | 5 | Cetus-GUI是基于web端的Cetus集群可视化管理系统,能有效的提升部署与管理Cetus集群的效率。 6 | 7 | **本项目当前仅适用于SaltStack环境下使用远程配置库安装配置多Cetus节点的需求。** 8 | 9 | --- 10 | 11 | ### 环境需求 12 | 13 | --- 14 | 15 | 环境要求:SaltStack Latest 16 | 17 | --- 18 | 19 | ### 安装 20 | 21 | --- 22 | 23 | **阅读 [help](./frontend/docs/HELP.md) 文档配置安装。** 24 | 25 | 目前项目支持docker安装与源码安装两种方式,推荐使用docker安装。 26 | 27 | --- 28 | 29 | ### 使用说明 30 | 31 | --- 32 | 33 | * 登陆 34 | 35 | * 项目启动后,直接访问http://localhost:9527(docker安装), http://localhost:9528(源码安装)登陆系统。 36 | * 默认用户名与密码为admin/admin,可在Django端新增用户。 37 | 38 | * 安装Cetus 39 | 40 |  41 | 42 | 可以在SaltStack环境下的Minion节点安装Cetus,通过安装多节点可以配置Cetus端的负载均衡。 43 | 44 | 提交安装请求后,若安装失败将在任务列表中显示对应log信息。 45 | 46 | * Cetus列表 47 | 48 |  49 | 50 | 显示所有Cetus运行或安装中的状态,点击查看可以查看Cetus详细信息,点击编辑可以修改Cetus基本信息。 51 | 52 | * Cetus详情 53 | 54 |  55 | 56 | 支持Cetus信息状态查询,节点的启动、关闭、更新、删除、新增等操作。 57 | 58 | * Cetus配置 59 | 60 |  61 | 62 | 支持Cetus基础参数的修改,用户与变量信息修改,分片信息修改,重启、更新、删除全部节点等功能。 63 | 64 | * 基础参数修改 65 | 66 |  67 | 68 | 注意字体加粗的为静态参数,需要手动重启Cetus客户端才能生效。 69 | 70 | * 用户和变量信息修改 71 | 72 |  73 | 74 | 其中用户名在Cetus端和MySQL端是一致的。密码分为客户端密码和服务端密码两种。 75 | 客户端密码为客户端连接Cetus时的密码,服务端密码为Cetus端连接数据库的密码,两者可以不同。 76 | 新增用户后也需要重启Cetus客户端来使信息生效。 77 | 78 | * 分片信息修改 79 | 80 |  81 | 82 | 分片信息可在Cetus为分片版本时修改,具体的配置方式请参考https://github.com/Lede-Inc/cetus/blob/master/doc/cetus-shard-profile.md。 83 | 84 | * Cetus管理命令 85 | 86 |  87 | 88 | 支持直接在web端执行命令发送到Cetus管理端。 89 | 90 | 具体支持的命令请参考: 91 | 92 | * 读写分离版:https://github.com/Lede-Inc/cetus/blob/master/doc/cetus-rw-admin.md 93 | * 分片版:https://github.com/Lede-Inc/cetus/blob/master/doc/cetus-shard-admin.md 94 | 95 | * Cetus监控 96 | 97 |  98 | 99 | Cetus在默认安装完成后会自动部署脚本,每分钟收集一次监控信息。系统默认收集了backends信息,连接数信息,TPS/QPS信息等内容。 100 | 101 | * 任务执行查询 102 | 103 | 由于Master与Minion节点系统环境的不确定性,安装Cetus时会因各种情况报错,我们可以在任务列表中查看失败的任务。 104 | 105 |  106 | 107 | 我们也可以直接查询应用日志定位问题,如果日志中的信息无法帮你准备定位并解决问题,请联系我们。 108 | 109 | --- 110 | 111 | ### TODO 112 | 113 | --- 114 | 115 | ``` 116 | 本地Cetus监控 117 | ``` 118 | 119 | -------------------------------------------------------------------------------- /backend/backend/__init__.py: -------------------------------------------------------------------------------- 1 | import pymysql 2 | pymysql.install_as_MySQLdb() 3 | -------------------------------------------------------------------------------- /backend/backend/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url, include 2 | from django.contrib import admin 3 | from rest_framework import routers 4 | from rest_framework_jwt.views import obtain_jwt_token 5 | 6 | from cetus import views, tasks 7 | 8 | router = routers.DefaultRouter() 9 | router.register(r'cetus', views.CetusViewSet) 10 | router.register(r'node', views.CetusNodeViewSet) 11 | router.register(r'task', tasks.TaskStatusSet) 12 | 13 | urlpatterns = [ 14 | url(r'^admin/', admin.site.urls), 15 | url(r'^api/', include(router.urls)), 16 | url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), 17 | 18 | url(r'^login/', obtain_jwt_token), 19 | ] 20 | -------------------------------------------------------------------------------- /backend/backend/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for backend project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /backend/cetus/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/backend/cetus/__init__.py -------------------------------------------------------------------------------- /backend/cetus/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /backend/cetus/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CetusConfig(AppConfig): 5 | name = 'cetus' 6 | -------------------------------------------------------------------------------- /backend/cetus/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from datetime import datetime 3 | 4 | 5 | class TbCetusGroupInfo(models.Model): 6 | CETUS_TYPE = ( 7 | ("rw", "读写分离版"), 8 | ("shard", "分片版"), 9 | ) 10 | cetus_name = models.CharField(max_length=20, verbose_name="Cetus名称") 11 | cetus_type = models.CharField(max_length=10, choices=CETUS_TYPE, verbose_name="Cetus类型") 12 | config_db = models.CharField(max_length=20, null=True, verbose_name="配置库库名") 13 | create_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") 14 | update_time = models.DateTimeField(null=True, verbose_name="更新时间") 15 | 16 | 17 | class Meta: 18 | verbose_name = "Cetus服务" 19 | verbose_name_plural = verbose_name 20 | db_table = "tb_cetus_group_info" 21 | 22 | 23 | class TbCetusNodeInfo(models.Model): 24 | group = models.ForeignKey(TbCetusGroupInfo, on_delete=models.CASCADE, verbose_name="节点所属组", related_name='nodes') 25 | salt_id = models.CharField(max_length=50, verbose_name="SALT ID") 26 | service_port = models.IntegerField(verbose_name="服务端口") 27 | admin_port = models.IntegerField(verbose_name="管理端口") 28 | version = models.CharField(max_length=100, null=True, verbose_name="版本") 29 | dir = models.CharField(max_length=200, null=True, verbose_name="路径") 30 | status = models.IntegerField(default=1, verbose_name="节点状态") 31 | create_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") 32 | update_time = models.DateTimeField(null=True, verbose_name="更新时间") 33 | 34 | class Meta: 35 | verbose_name = "Cetus节点" 36 | verbose_name_plural = verbose_name 37 | db_table = "tb_cetus_node_info" 38 | 39 | 40 | -------------------------------------------------------------------------------- /backend/cetus/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | 3 | from .models import TbCetusGroupInfo, TbCetusNodeInfo 4 | from djcelery.models import TaskState 5 | 6 | 7 | class CetusNodeSerializer(serializers.ModelSerializer): 8 | class Meta: 9 | model = TbCetusNodeInfo 10 | fields = "__all__" 11 | 12 | 13 | class CetusGroupSerializer(serializers.ModelSerializer): 14 | nodes = CetusNodeSerializer(read_only=True, many=True) 15 | 16 | class Meta: 17 | model = TbCetusGroupInfo 18 | fields = "__all__" 19 | 20 | 21 | class TaskStatusSerializer(serializers.ModelSerializer): 22 | class Meta: 23 | model = TaskState 24 | fields = "__all__" 25 | -------------------------------------------------------------------------------- /backend/cetus/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /backend/install/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | cetus_gui_db: 5 | container_name: cetus_gui_db 6 | image: mysql:5.7 7 | volumes: 8 | - ./mysql/:/etc/mysql/conf.d/ 9 | - ./data/:/var/lib/mysql/ 10 | restart: always 11 | ports: 12 | - "3306:3306" 13 | environment: 14 | MYSQL_ROOT_PASSWORD: cetus_password 15 | MYSQL_DATABASE: cetus_gui 16 | MYSQL_USER: cetus 17 | MYSQL_PASSWORD: cetus 18 | cetus_gui_app: 19 | container_name: cetus_gui_app 20 | image: hub.c.163.com/mikuru333/cetus-gui:v0.0.1 21 | restart: always 22 | depends_on: 23 | - cetus_gui_db 24 | ports: 25 | - "9527:80" 26 | - "8300:8000" 27 | - "4505:4505" 28 | - "4506:4506" 29 | stdin_open: true 30 | tty: true -------------------------------------------------------------------------------- /backend/install/mysql/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | default-character-set = utf8 3 | 4 | [mysql] 5 | default-character-set = utf8 6 | 7 | [mysqld] 8 | character-set-client-handshake = FALSE 9 | character-set-server = utf8 10 | collation-server = utf8_unicode_ci 11 | init_connect='SET NAMES utf8' -------------------------------------------------------------------------------- /backend/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /backend/requirement.txt: -------------------------------------------------------------------------------- 1 | celery==3.1.26.post2 2 | Django==2.0.11 3 | django-celery==3.2.2 4 | django-cors-middleware==1.3.1 5 | django-filter==2.0.0 6 | djangorestframework==3.8.2 7 | djangorestframework-filter==0.2.2 8 | djangorestframework-jwt==1.11.0 9 | PyMySQL==0.9.2 10 | salt==2018.3.3 11 | urllib3==1.23 12 | uWSGI==2.0.17.1 13 | -------------------------------------------------------------------------------- /backend/shells/cetus_monitor.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | import getopt 6 | import pymysql 7 | import subprocess 8 | 9 | 10 | def help_and_exit(): 11 | print('''Usage: 12 | -h 显示帮助信息 13 | -P 端口 14 | -u 用户 15 | -p 密码 16 | -d 数据库 17 | ''') 18 | sys.exit() 19 | 20 | 21 | def get_cpu_mem(pid): 22 | try: 23 | p = subprocess.Popen("ps aux|grep %s|grep -v 'grep'|awk '{print $3}'" % pid, 24 | shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) 25 | cpu = p.stdout.read().strip() 26 | p = subprocess.Popen("ps aux|grep %s|grep -v 'grep'|awk '{print $6}'" % pid, 27 | shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) 28 | mem = p.stdout.read().strip() 29 | 30 | return bytes.decode(cpu), bytes.decode(mem) 31 | except Exception as e: 32 | print(e) 33 | return 0, 0 34 | 35 | 36 | def main(): 37 | try: 38 | opts, args = getopt.getopt(sys.argv[1:], 39 | 'hP:u:p:', 40 | ['help', 'port=', 'user=', 'passwd=']) 41 | 42 | except getopt.GetoptError as err: 43 | print(err) 44 | help_and_exit() 45 | 46 | for opt, arg in opts: 47 | if opt in ('-h', '--help',): 48 | help_and_exit() 49 | elif opt in ('-P', '--port'): 50 | port = arg 51 | elif opt in ('-u', '--user'): 52 | user = arg 53 | elif opt in ('-p', '--passwd'): 54 | passwd = arg 55 | 56 | try: 57 | db = pymysql.connect(host='127.0.0.1', user=user, passwd=passwd, port=int(port), autocommit=None) 58 | cursor = db.cursor() 59 | except Exception as e: 60 | print(e) 61 | raise Exception('数据库连接失败') 62 | 63 | try: 64 | res_list, pid = list(), str() 65 | 66 | cursor.execute('cetus') 67 | for item in cursor.fetchall(): 68 | if item[1] == 'Startup time': 69 | pid = item[0] 70 | res_list.append(('startup_time', item[2])) 71 | if item[1] == 'Loaded modules': 72 | res_list.append(('modules', item[2])) 73 | if item[1] == 'Idle backend connections': 74 | res_list.append(('idle_conns', item[2])) 75 | if item[1] == 'Used backend connections': 76 | res_list.append(('used_conns', item[2])) 77 | if item[1] == 'Client connections': 78 | res_list.append(('client_conns', item[2])) 79 | if item[1] == 'Query count': 80 | res_list.append(('query_count', item[2])) 81 | if item[1] == 'QPS (1min, 5min, 15min)': 82 | _u = item[2].split(',') 83 | res_list.append(('qps1', _u[0].strip())) 84 | res_list.append(('qps5', _u[1].strip())) 85 | res_list.append(('qps15', _u[2].strip())) 86 | if item[1] == 'TPS (1min, 5min, 15min)': 87 | _u = item[2].split(',') 88 | res_list.append(('tps1', _u[0].strip())) 89 | res_list.append(('tps5', _u[1].strip())) 90 | res_list.append(('tps15', _u[2].strip())) 91 | 92 | backends_list = list() 93 | cursor.execute('select * from backends') 94 | for item in cursor.fetchall(): 95 | backends_list.append(item[2:]) 96 | res_list.append(('backends', str(backends_list))) 97 | 98 | cpu, mem = get_cpu_mem(pid) 99 | res_list.extend([('cpu', cpu), ('mem', mem)]) 100 | 101 | cursor.execute('show status') 102 | for item in cursor.fetchall(): 103 | res_list.append((item[1], item[2])) 104 | 105 | return 0, res_list 106 | 107 | except Exception as e: 108 | print(e) 109 | raise Exception('数据查询失败') 110 | finally: 111 | db.close() 112 | 113 | 114 | if __name__ == '__main__': 115 | ret, msg = main() 116 | print(msg) 117 | sys.exit(ret) 118 | -------------------------------------------------------------------------------- /backend/shells/check_cetus.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import getopt 5 | import sys 6 | import pymysql 7 | 8 | 9 | def help_and_exit(): 10 | print('''Usage: 11 | -h 显示帮助信息 12 | -u 用户 13 | -p 密码 14 | -P 端口 15 | ''') 16 | sys.exit() 17 | 18 | 19 | def main(): 20 | try: 21 | opts, args = getopt.getopt(sys.argv[1:], 22 | 'hu:p:P:', 23 | ['help', 'user=', 'passwd=', 'port=']) 24 | 25 | except getopt.GetoptError as err: 26 | print(err) 27 | help_and_exit() 28 | 29 | for opt, arg in opts: 30 | if opt in ('-h', '--help'): 31 | help_and_exit() 32 | elif opt in ('-u', '--user'): 33 | user = arg 34 | elif opt in ('-p', '--passwd'): 35 | password = arg 36 | elif opt in ('-P', '--port'): 37 | port = arg 38 | 39 | try: 40 | conn = pymysql.connect(host='127.0.0.1', user=user, passwd=password, port=int(port), autocommit=None) 41 | cursor = conn.cursor() 42 | res = cursor.execute('select version') 43 | if res == 1: 44 | return 0, 'success' 45 | except Exception as e: 46 | return 1, e 47 | 48 | 49 | if __name__ == '__main__': 50 | ret, msg = main() 51 | print(ret) 52 | print(msg) 53 | sys.exit(ret) 54 | -------------------------------------------------------------------------------- /backend/shells/download_cetus.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import sys 4 | import subprocess 5 | import os 6 | import getopt 7 | import shutil 8 | 9 | 10 | def help_and_exit(): 11 | print('''Usage: 12 | -h 显示帮助信息 13 | -u 下载地址 14 | -t 类型 15 | -r 路径 16 | -v 版本号 17 | ''') 18 | sys.exit() 19 | 20 | 21 | def download_cetus(**kwargs): 22 | try: 23 | shutil.rmtree(kwargs.get('cetus_route'), ignore_errors=True) 24 | p = subprocess.Popen('git clone {cetus_url} {cetus_route}'.format(**kwargs), 25 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 26 | p.communicate() 27 | if os.path.isdir(kwargs.get('cetus_route')): 28 | os.chdir(kwargs.get('cetus_route')) 29 | cmd = 'git log --pretty=format:%ad.%h --date=short -n1;' 30 | if kwargs.get('cetus_version') != 'null': 31 | cmd = 'git checkout {cetus_version};'.format(**kwargs) + cmd 32 | p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 33 | o = bytes.decode(p.communicate()[0]).replace('-', '') 34 | else: 35 | raise Exception('下载失败') 36 | return 0, o 37 | except Exception as e: 38 | print(e) 39 | return 1, e 40 | 41 | 42 | def main(): 43 | try: 44 | opts, args = getopt.getopt(sys.argv[1:], 45 | 'ht:v:u:r:', 46 | ['help', 'type=', 'version=', 'url=', 'route=']) 47 | 48 | except getopt.GetoptError as err: 49 | print(err) 50 | help_and_exit() 51 | 52 | cetus_url = 'https://github.com/Lede-Inc/cetus' 53 | cetus_route = '/tmp/cetus_mirror' 54 | cetus_version = 'null' 55 | cetus_type = 'rw' 56 | for opt, arg in opts: 57 | if opt in ('-h', '--help'): 58 | help_and_exit() 59 | elif opt in ('-t', '--type'): 60 | cetus_type = arg 61 | elif opt in ('-v', '--version'): 62 | cetus_version = arg 63 | elif opt in ('-u', '--url'): 64 | cetus_url = arg 65 | elif opt in ('-r', '--route'): 66 | cetus_route = arg 67 | 68 | code, cetus_version = download_cetus(**locals()) 69 | return code, 'cetus.{cetus_type}.{cetus_version}'.format(**locals()) 70 | 71 | 72 | if __name__ == '__main__': 73 | ret, msg = main() 74 | print(msg) 75 | sys.exit(ret) 76 | -------------------------------------------------------------------------------- /backend/shells/install_cetus.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import subprocess 5 | import sys 6 | import os 7 | import getopt 8 | import socket 9 | import shutil 10 | 11 | 12 | def help_and_exit(): 13 | print('''Usage: 14 | -h 显示帮助信息 15 | -t Cetus类型 16 | -p 服务端口 17 | -a 管理端口 18 | -b 分支 19 | -d Cetus目录 20 | ''') 21 | sys.exit() 22 | 23 | 24 | def check_socket(port_list): 25 | for index in port_list: 26 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 27 | result = sock.connect_ex(('127.0.0.1', int(index))) 28 | sock.close() 29 | if not result: 30 | raise Exception('端口已被占用') 31 | 32 | 33 | def create_environment(user, cetus_path): 34 | try: 35 | os.system('useradd %s' % user) 36 | p = subprocess.Popen('sudo yum install cmake gcc glib2-devel flex mysql-devel gperftools-libs git -y', 37 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 38 | p.communicate() 39 | path = cetus_path[:cetus_path.rfind('/')] + '/logs' 40 | if not os.path.exists(path): 41 | os.makedirs(path) 42 | os.system('chown -R %s:%s %s' % (user, user, path)) 43 | except Exception as e: 44 | print(e) 45 | raise Exception('环境初始化失败') 46 | 47 | 48 | def install_cetus(cetus_type, cetus_route, cetus_path, user): 49 | try: 50 | os.chdir(cetus_route) 51 | cetus_type = 'ON' if cetus_type == 'rw' else 'OFF' 52 | 53 | p = subprocess.Popen('mkdir build && cd build && cmake ../ -DCMAKE_BUILD_TYPE=Debug ' 54 | '-DCMAKE_INSTALL_PREFIX=%s -DSIMPLE_PARSER=%s && make install' % (cetus_path, cetus_type), 55 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 56 | p.communicate() 57 | os.system('chown -R %s:%s %s' % (user, user, cetus_path[:cetus_path.rfind('/')])) 58 | except Exception as e: 59 | print(e) 60 | raise Exception('安装失败') 61 | finally: 62 | shutil.rmtree(cetus_route, ignore_errors=True) 63 | 64 | 65 | def main(): 66 | try: 67 | opts, args = getopt.getopt(sys.argv[1:], 68 | 'ht:s:a:r:p:', 69 | ['help', 'type=', 'service=', 'admin=', 'route=', 'path=']) 70 | except getopt.GetoptError as err: 71 | print(err) 72 | help_and_exit() 73 | 74 | for opt, arg in opts: 75 | if opt in ('-h', '--help'): 76 | help_and_exit() 77 | elif opt in ('-t', '--type'): 78 | cetus_type = arg 79 | elif opt in ('-s', '--service'): 80 | service_port = arg 81 | elif opt in ('-a', '--admin'): 82 | admin_port = arg 83 | elif opt in ('-r', '--route'): 84 | cetus_route = arg 85 | elif opt in ('-p', '--path'): 86 | cetus_path = arg 87 | 88 | try: 89 | check_socket([service_port, admin_port]) 90 | user = 'cetus_%s' % service_port 91 | create_environment(user, cetus_path) 92 | install_cetus(cetus_type, cetus_route, cetus_path, user) 93 | return 0, '安装成功' 94 | 95 | except Exception as e: 96 | print(e) 97 | return 1, e 98 | 99 | 100 | if __name__ == '__main__': 101 | ret, msg = main() 102 | sys.exit(ret) 103 | -------------------------------------------------------------------------------- /backend/shells/operate_cetus.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | import getopt 6 | import os 7 | import subprocess 8 | import pwd 9 | import signal 10 | from threading import Timer 11 | 12 | 13 | def help_and_exit(): 14 | print('''Usage: 15 | -h 显示帮助信息 16 | -u 下载地址 17 | -t 类型 18 | -r 路径 19 | -v 版本号 20 | ''') 21 | sys.exit() 22 | 23 | 24 | def change_user(username): 25 | user_info = pwd.getpwnam(username) 26 | os.setgid(user_info.pw_gid) 27 | os.setuid(user_info.pw_uid) 28 | 29 | 30 | def start_cetus(**kwargs): 31 | try: 32 | os.chdir(kwargs.get('cetus_route')) 33 | change_user(kwargs.get('cetus_owner')) 34 | print('{cetus_route}/bin/cetus --remote-conf-url=' 35 | 'mysql://{user}:{passwd}@{host}:{port}/{database} 1>/dev/null 2>&1'.format(**kwargs)) 36 | 37 | kill = lambda process: process.kill() 38 | p = subprocess.Popen('{cetus_route}/bin/cetus --remote-conf-url=' 39 | 'mysql://{user}:{passwd}@{host}:{port}/{database} &> /dev/null'.format(**kwargs), 40 | shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 41 | job = Timer(5, kill, [p]) 42 | try: 43 | job.start() 44 | finally: 45 | job.cancel() 46 | 47 | return 0, 'success' 48 | 49 | # if p.returncode == 0: 50 | # return 0, 'success' 51 | # else: 52 | # raise Exception('failure') 53 | except Exception as e: 54 | return 1, e 55 | 56 | 57 | def shutdown_cetus(**kwargs): 58 | return shutdown_abort_cetus(**kwargs) 59 | 60 | 61 | def shutdown_abort_cetus(**kwargs): 62 | try: 63 | pid_path = '%s/%s.pid' % (kwargs.get('cetus_route')[:kwargs.get('cetus_route').rfind('/')], 64 | kwargs.get('cetus_owner')) 65 | if os.path.exists(pid_path): 66 | with open(pid_path, 'r') as f: 67 | pid_list = [int(f.read())] 68 | else: 69 | cmd = 'remote-conf-url.*' + kwargs.get('database') 70 | child = subprocess.Popen(['pgrep', '-f', cmd], 71 | shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 72 | out = child.communicate()[0] 73 | pid_list = [int(pid) for pid in out.split()] 74 | for item in pid_list: 75 | os.kill(item, signal.SIGKILL) 76 | tmp_path = '/tmp/0.0.0.0:' + kwargs.get('admin_port') 77 | os.remove(tmp_path) if os.path.exists(tmp_path) else None 78 | return 0, 'success' 79 | except Exception as e: 80 | return 1, e 81 | 82 | 83 | def restart_cetus(**kwargs): 84 | shutdown_abort_cetus(**kwargs) 85 | return start_cetus(**kwargs) 86 | 87 | 88 | def main(): 89 | try: 90 | opts, args = getopt.getopt(sys.argv[1:], 91 | 't:h:P:u:p:d:r:o:a:', 92 | ['help', 'type=', 'host=', 'port=', 'user=', 'passwd=', 'database=', 'route=', 'owner=', 'admin=']) 93 | 94 | except getopt.GetoptError as err: 95 | print(err) 96 | help_and_exit() 97 | 98 | for opt, arg in opts: 99 | if opt in ('--help',): 100 | help_and_exit() 101 | elif opt in ('-t', '--type'): 102 | operate_type = arg 103 | elif opt in ('-h', '--host'): 104 | host = arg 105 | elif opt in ('-P', '--port'): 106 | port = arg 107 | elif opt in ('-u', '--user'): 108 | user = arg 109 | elif opt in ('-p', '--passwd'): 110 | passwd = arg 111 | elif opt in ('-d', '--database'): 112 | database = arg 113 | elif opt in ('-r', '--route'): 114 | cetus_route = arg 115 | elif opt in ('-o', '--owner'): 116 | cetus_owner = arg 117 | elif opt in ('-a', '--admin'): 118 | admin_port = arg 119 | 120 | if operate_type == 'start': 121 | res = start_cetus(**locals()) 122 | elif operate_type == 'shutdown': 123 | res = shutdown_cetus(**locals()) 124 | elif operate_type == 'restart': 125 | res = restart_cetus(**locals()) 126 | elif operate_type == 'abort': 127 | res = shutdown_abort_cetus(**locals()) 128 | 129 | return res 130 | 131 | 132 | if __name__ == '__main__': 133 | ret, msg = main() 134 | print(msg) 135 | sys.exit(ret) 136 | -------------------------------------------------------------------------------- /backend/uwsgi.cnf: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | 3 | http=0.0.0.0:8000 4 | wsgi-file=backend/wsgi.py 5 | static-map=/static=static 6 | processes=4 7 | threads=2 8 | 9 | close-on-exec 10 | vacuum=true 11 | master=true -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo yum install -y gcc gcc-c++ python34 python34-devel python34-pip erlang rabbitmq-server nodejs 4 | sudo service rabbitmq-server start 5 | sudo rabbitmqctl start_app 6 | sudo pip3 install virtualenv 7 | sudo pip2 install supervisor 8 | virtualenv -p python3 cetus_env 9 | source cetus_env/bin/activate 10 | mkdir logs 11 | 12 | cd backend/ 13 | pip install -r requirement.txt 14 | python manage.py makemigrations 15 | python manage.py makemigrations cetus 16 | python manage.py migrate 17 | echo "from django.contrib.auth import get_user_model; User = get_user_model(); 18 | User.objects.create_superuser('admin', '', 'admin') if not User.objects.filter(username='admin') else 0;" | python manage.py shell 19 | 20 | cd ../frontend/ 21 | npm install 22 | 23 | cd .. 24 | supervisord -c supervisor.cnf 25 | supervisorctl restart backend beat celerycam cetus frontend monitor 26 | -------------------------------------------------------------------------------- /frontend/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] 7 | } 8 | }], 9 | "stage-2" 10 | ], 11 | "plugins":["transform-vue-jsx", "transform-runtime"] 12 | } 13 | -------------------------------------------------------------------------------- /frontend/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | insert_final_newline = false 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /frontend/.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | src/assets 4 | -------------------------------------------------------------------------------- /frontend/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | parser: 'babel-eslint', 5 | sourceType: 'module' 6 | }, 7 | env: { 8 | browser: true, 9 | node: true, 10 | es6: true, 11 | }, 12 | extends: ['plugin:vue/recommended', 'eslint:recommended'], 13 | 14 | // add your custom rules here 15 | //it is base on https://github.com/vuejs/eslint-config-vue 16 | rules: { 17 | "vue/max-attributes-per-line": [2, { 18 | "singleline": 10, 19 | "multiline": { 20 | "max": 1, 21 | "allowFirstLine": false 22 | } 23 | }], 24 | "vue/name-property-casing": ["error", "PascalCase"], 25 | 'accessor-pairs': 2, 26 | 'arrow-spacing': [2, { 27 | 'before': true, 28 | 'after': true 29 | }], 30 | 'block-spacing': [2, 'always'], 31 | 'brace-style': [2, '1tbs', { 32 | 'allowSingleLine': true 33 | }], 34 | 'camelcase': [0, { 35 | 'properties': 'always' 36 | }], 37 | 'comma-dangle': [2, 'never'], 38 | 'comma-spacing': [2, { 39 | 'before': false, 40 | 'after': true 41 | }], 42 | 'comma-style': [2, 'last'], 43 | 'constructor-super': 2, 44 | 'curly': [2, 'multi-line'], 45 | 'dot-location': [2, 'property'], 46 | 'eol-last': 2, 47 | 'eqeqeq': [2, 'allow-null'], 48 | 'generator-star-spacing': [2, { 49 | 'before': true, 50 | 'after': true 51 | }], 52 | 'handle-callback-err': [2, '^(err|error)$'], 53 | 'indent': [2, 2, { 54 | 'SwitchCase': 1 55 | }], 56 | 'jsx-quotes': [2, 'prefer-single'], 57 | 'key-spacing': [2, { 58 | 'beforeColon': false, 59 | 'afterColon': true 60 | }], 61 | 'keyword-spacing': [2, { 62 | 'before': true, 63 | 'after': true 64 | }], 65 | 'new-cap': [2, { 66 | 'newIsCap': true, 67 | 'capIsNew': false 68 | }], 69 | 'new-parens': 2, 70 | 'no-array-constructor': 2, 71 | 'no-caller': 2, 72 | 'no-console': 'off', 73 | 'no-class-assign': 2, 74 | 'no-cond-assign': 2, 75 | 'no-const-assign': 2, 76 | 'no-control-regex': 2, 77 | 'no-delete-var': 2, 78 | 'no-dupe-args': 2, 79 | 'no-dupe-class-members': 2, 80 | 'no-dupe-keys': 2, 81 | 'no-duplicate-case': 2, 82 | 'no-empty-character-class': 2, 83 | 'no-empty-pattern': 2, 84 | 'no-eval': 2, 85 | 'no-ex-assign': 2, 86 | 'no-extend-native': 2, 87 | 'no-extra-bind': 2, 88 | 'no-extra-boolean-cast': 2, 89 | 'no-extra-parens': [2, 'functions'], 90 | 'no-fallthrough': 2, 91 | 'no-floating-decimal': 2, 92 | 'no-func-assign': 2, 93 | 'no-implied-eval': 2, 94 | 'no-inner-declarations': [2, 'functions'], 95 | 'no-invalid-regexp': 2, 96 | 'no-irregular-whitespace': 2, 97 | 'no-iterator': 2, 98 | 'no-label-var': 2, 99 | 'no-labels': [2, { 100 | 'allowLoop': false, 101 | 'allowSwitch': false 102 | }], 103 | 'no-lone-blocks': 2, 104 | 'no-mixed-spaces-and-tabs': 2, 105 | 'no-multi-spaces': 2, 106 | 'no-multi-str': 2, 107 | 'no-multiple-empty-lines': [2, { 108 | 'max': 1 109 | }], 110 | 'no-native-reassign': 2, 111 | 'no-negated-in-lhs': 2, 112 | 'no-new-object': 2, 113 | 'no-new-require': 2, 114 | 'no-new-symbol': 2, 115 | 'no-new-wrappers': 2, 116 | 'no-obj-calls': 2, 117 | 'no-octal': 2, 118 | 'no-octal-escape': 2, 119 | 'no-path-concat': 2, 120 | 'no-proto': 2, 121 | 'no-redeclare': 2, 122 | 'no-regex-spaces': 2, 123 | 'no-return-assign': [2, 'except-parens'], 124 | 'no-self-assign': 2, 125 | 'no-self-compare': 2, 126 | 'no-sequences': 2, 127 | 'no-shadow-restricted-names': 2, 128 | 'no-spaced-func': 2, 129 | 'no-sparse-arrays': 2, 130 | 'no-this-before-super': 2, 131 | 'no-throw-literal': 2, 132 | 'no-trailing-spaces': 2, 133 | 'no-undef': 2, 134 | 'no-undef-init': 2, 135 | 'no-unexpected-multiline': 2, 136 | 'no-unmodified-loop-condition': 2, 137 | 'no-unneeded-ternary': [2, { 138 | 'defaultAssignment': false 139 | }], 140 | 'no-unreachable': 2, 141 | 'no-unsafe-finally': 2, 142 | 'no-unused-vars': [2, { 143 | 'vars': 'all', 144 | 'args': 'none' 145 | }], 146 | 'no-useless-call': 2, 147 | 'no-useless-computed-key': 2, 148 | 'no-useless-constructor': 2, 149 | 'no-useless-escape': 0, 150 | 'no-whitespace-before-property': 2, 151 | 'no-with': 2, 152 | 'one-var': [2, { 153 | 'initialized': 'never' 154 | }], 155 | 'operator-linebreak': [2, 'after', { 156 | 'overrides': { 157 | '?': 'before', 158 | ':': 'before' 159 | } 160 | }], 161 | 'padded-blocks': [2, 'never'], 162 | 'quotes': [2, 'single', { 163 | 'avoidEscape': true, 164 | 'allowTemplateLiterals': true 165 | }], 166 | 'semi': [2, 'never'], 167 | 'semi-spacing': [2, { 168 | 'before': false, 169 | 'after': true 170 | }], 171 | 'space-before-blocks': [2, 'always'], 172 | 'space-before-function-paren': [2, 'never'], 173 | 'space-in-parens': [2, 'never'], 174 | 'space-infix-ops': 2, 175 | 'space-unary-ops': [2, { 176 | 'words': true, 177 | 'nonwords': false 178 | }], 179 | 'spaced-comment': [2, 'always', { 180 | 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] 181 | }], 182 | 'template-curly-spacing': [2, 'never'], 183 | 'use-isnan': 2, 184 | 'valid-typeof': 2, 185 | 'wrap-iife': [2, 'any'], 186 | 'yield-star-spacing': [2, 'both'], 187 | 'yoda': [2, 'never'], 188 | 'prefer-const': 2, 189 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 190 | 'object-curly-spacing': [2, 'always', { 191 | objectsInObjects: false 192 | }], 193 | 'array-bracket-spacing': [2, 'never'] 194 | } 195 | } 196 | 197 | -------------------------------------------------------------------------------- /frontend/.postcssrc.js: -------------------------------------------------------------------------------- 1 | // https://github.com/michael-ciniawsky/postcss-load-config 2 | 3 | module.exports = { 4 | "plugins": { 5 | "postcss-import": {}, 6 | "postcss-url": {}, 7 | // to edit target browsers: use "browserslist" field in package.json 8 | "autoprefixer": {} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /frontend/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: stable 3 | script: npm run test 4 | notifications: 5 | email: false 6 | -------------------------------------------------------------------------------- /frontend/build/build.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | const ora = require('ora') 7 | const rm = require('rimraf') 8 | const path = require('path') 9 | const chalk = require('chalk') 10 | const webpack = require('webpack') 11 | const config = require('../config') 12 | const webpackConfig = require('./webpack.prod.conf') 13 | 14 | const spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { 18 | if (err) throw err 19 | webpack(webpackConfig, (err, stats) => { 20 | spinner.stop() 21 | if (err) throw err 22 | process.stdout.write( 23 | stats.toString({ 24 | colors: true, 25 | modules: false, 26 | children: false, 27 | chunks: false, 28 | chunkModules: false 29 | }) + '\n\n' 30 | ) 31 | 32 | if (stats.hasErrors()) { 33 | console.log(chalk.red(' Build failed with errors.\n')) 34 | process.exit(1) 35 | } 36 | 37 | console.log(chalk.cyan(' Build complete.\n')) 38 | console.log( 39 | chalk.yellow( 40 | ' Tip: built files are meant to be served over an HTTP server.\n' + 41 | " Opening index.html over file:// won't work.\n" 42 | ) 43 | ) 44 | }) 45 | }) 46 | -------------------------------------------------------------------------------- /frontend/build/check-versions.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const chalk = require('chalk') 3 | const semver = require('semver') 4 | const packageConfig = require('../package.json') 5 | const shell = require('shelljs') 6 | 7 | function exec(cmd) { 8 | return require('child_process') 9 | .execSync(cmd) 10 | .toString() 11 | .trim() 12 | } 13 | 14 | const versionRequirements = [ 15 | { 16 | name: 'node', 17 | currentVersion: semver.clean(process.version), 18 | versionRequirement: packageConfig.engines.node 19 | } 20 | ] 21 | 22 | if (shell.which('npm')) { 23 | versionRequirements.push({ 24 | name: 'npm', 25 | currentVersion: exec('npm --version'), 26 | versionRequirement: packageConfig.engines.npm 27 | }) 28 | } 29 | 30 | module.exports = function() { 31 | const warnings = [] 32 | 33 | for (let i = 0; i < versionRequirements.length; i++) { 34 | const mod = versionRequirements[i] 35 | 36 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 37 | warnings.push( 38 | mod.name + 39 | ': ' + 40 | chalk.red(mod.currentVersion) + 41 | ' should be ' + 42 | chalk.green(mod.versionRequirement) 43 | ) 44 | } 45 | } 46 | 47 | if (warnings.length) { 48 | console.log('') 49 | console.log( 50 | chalk.yellow( 51 | 'To use this template, you must update following to modules:' 52 | ) 53 | ) 54 | console.log() 55 | 56 | for (let i = 0; i < warnings.length; i++) { 57 | const warning = warnings[i] 58 | console.log(' ' + warning) 59 | } 60 | 61 | console.log() 62 | process.exit(1) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /frontend/build/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/build/logo.png -------------------------------------------------------------------------------- /frontend/build/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const config = require('../config') 4 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 5 | const packageConfig = require('../package.json') 6 | 7 | exports.assetsPath = function(_path) { 8 | const assetsSubDirectory = 9 | process.env.NODE_ENV === 'production' 10 | ? config.build.assetsSubDirectory 11 | : config.dev.assetsSubDirectory 12 | 13 | return path.posix.join(assetsSubDirectory, _path) 14 | } 15 | 16 | exports.cssLoaders = function(options) { 17 | options = options || {} 18 | 19 | const cssLoader = { 20 | loader: 'css-loader', 21 | options: { 22 | sourceMap: options.sourceMap 23 | } 24 | } 25 | 26 | const postcssLoader = { 27 | loader: 'postcss-loader', 28 | options: { 29 | sourceMap: options.sourceMap 30 | } 31 | } 32 | 33 | // generate loader string to be used with extract text plugin 34 | function generateLoaders(loader, loaderOptions) { 35 | const loaders = [] 36 | 37 | // Extract CSS when that option is specified 38 | // (which is the case during production build) 39 | if (options.extract) { 40 | loaders.push(MiniCssExtractPlugin.loader) 41 | } else { 42 | loaders.push('vue-style-loader') 43 | } 44 | 45 | loaders.push(cssLoader) 46 | 47 | if (options.usePostCSS) { 48 | loaders.push(postcssLoader) 49 | } 50 | 51 | if (loader) { 52 | loaders.push({ 53 | loader: loader + '-loader', 54 | options: Object.assign({}, loaderOptions, { 55 | sourceMap: options.sourceMap 56 | }) 57 | }) 58 | } 59 | 60 | return loaders 61 | } 62 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html 63 | return { 64 | css: generateLoaders(), 65 | postcss: generateLoaders(), 66 | less: generateLoaders('less'), 67 | sass: generateLoaders('sass', { 68 | indentedSyntax: true 69 | }), 70 | scss: generateLoaders('sass'), 71 | stylus: generateLoaders('stylus'), 72 | styl: generateLoaders('stylus') 73 | } 74 | } 75 | 76 | // Generate loaders for standalone style files (outside of .vue) 77 | exports.styleLoaders = function(options) { 78 | const output = [] 79 | const loaders = exports.cssLoaders(options) 80 | 81 | for (const extension in loaders) { 82 | const loader = loaders[extension] 83 | output.push({ 84 | test: new RegExp('\\.' + extension + '$'), 85 | use: loader 86 | }) 87 | } 88 | 89 | return output 90 | } 91 | 92 | exports.createNotifierCallback = () => { 93 | const notifier = require('node-notifier') 94 | 95 | return (severity, errors) => { 96 | if (severity !== 'error') return 97 | 98 | const error = errors[0] 99 | const filename = error.file && error.file.split('!').pop() 100 | 101 | notifier.notify({ 102 | title: packageConfig.name, 103 | message: severity + ': ' + error.name, 104 | subtitle: filename || '', 105 | icon: path.join(__dirname, 'logo.png') 106 | }) 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /frontend/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | //You can set the vue-loader configuration by yourself. 5 | } 6 | -------------------------------------------------------------------------------- /frontend/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const config = require('../config') 5 | const { VueLoaderPlugin } = require('vue-loader') 6 | const vueLoaderConfig = require('./vue-loader.conf') 7 | 8 | function resolve(dir) { 9 | return path.join(__dirname, '..', dir) 10 | } 11 | 12 | const createLintingRule = () => ({ 13 | test: /\.(js|vue)$/, 14 | loader: 'eslint-loader', 15 | enforce: 'pre', 16 | include: [resolve('src'), resolve('test')], 17 | options: { 18 | formatter: require('eslint-friendly-formatter'), 19 | emitWarning: !config.dev.showEslintErrorsInOverlay 20 | } 21 | }) 22 | 23 | module.exports = { 24 | context: path.resolve(__dirname, '../'), 25 | entry: { 26 | app: './src/main.js' 27 | }, 28 | output: { 29 | path: config.build.assetsRoot, 30 | filename: '[name].js', 31 | publicPath: 32 | process.env.NODE_ENV === 'production' 33 | ? config.build.assetsPublicPath 34 | : config.dev.assetsPublicPath 35 | }, 36 | resolve: { 37 | extensions: ['.js', '.vue', '.json'], 38 | alias: { 39 | '@': resolve('src') 40 | } 41 | }, 42 | module: { 43 | rules: [ 44 | ...(config.dev.useEslint ? [createLintingRule()] : []), 45 | { 46 | test: /\.vue$/, 47 | loader: 'vue-loader', 48 | options: vueLoaderConfig 49 | }, 50 | { 51 | test: /\.js$/, 52 | loader: 'babel-loader', 53 | include: [ 54 | resolve('src'), 55 | resolve('test'), 56 | resolve('node_modules/webpack-dev-server/client') 57 | ] 58 | }, 59 | { 60 | test: /\.svg$/, 61 | loader: 'svg-sprite-loader', 62 | include: [resolve('src/icons')], 63 | options: { 64 | symbolId: 'icon-[name]' 65 | } 66 | }, 67 | { 68 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 69 | loader: 'url-loader', 70 | exclude: [resolve('src/icons')], 71 | options: { 72 | limit: 10000, 73 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 74 | } 75 | }, 76 | { 77 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 78 | loader: 'url-loader', 79 | options: { 80 | limit: 10000, 81 | name: utils.assetsPath('media/[name].[hash:7].[ext]') 82 | } 83 | }, 84 | { 85 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 86 | loader: 'url-loader', 87 | options: { 88 | limit: 10000, 89 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 90 | } 91 | }, 92 | { 93 | test: /\.md$/, 94 | use: [ 95 | { 96 | loader: 'vue-loader' 97 | }, 98 | { 99 | loader: 'vmark-loader' 100 | } 101 | ] 102 | } 103 | ] 104 | }, 105 | plugins: [new VueLoaderPlugin()], 106 | node: { 107 | // prevent webpack from injecting useless setImmediate polyfill because Vue 108 | // source contains it (although only uses it if it's native). 109 | setImmediate: false, 110 | // prevent webpack from injecting mocks to Node native modules 111 | // that does not make sense for the client 112 | dgram: 'empty', 113 | fs: 'empty', 114 | net: 'empty', 115 | tls: 'empty', 116 | child_process: 'empty' 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /frontend/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const webpack = require('webpack') 5 | const config = require('../config') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const HtmlWebpackPlugin = require('html-webpack-plugin') 9 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 10 | const portfinder = require('portfinder') 11 | 12 | function resolve(dir) { 13 | return path.join(__dirname, '..', dir) 14 | } 15 | 16 | const HOST = process.env.HOST 17 | const PORT = process.env.PORT && Number(process.env.PORT) 18 | 19 | const devWebpackConfig = merge(baseWebpackConfig, { 20 | mode: 'development', 21 | module: { 22 | rules: utils.styleLoaders({ 23 | sourceMap: config.dev.cssSourceMap, 24 | usePostCSS: true 25 | }) 26 | }, 27 | // cheap-module-eval-source-map is faster for development 28 | devtool: config.dev.devtool, 29 | 30 | // these devServer options should be customized in /config/index.js 31 | devServer: { 32 | clientLogLevel: 'warning', 33 | historyApiFallback: { 34 | rewrites: [ 35 | { from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, 36 | ], 37 | }, 38 | hot: true, 39 | contentBase: false, 40 | compress: true, 41 | host: HOST || config.dev.host, 42 | port: PORT || config.dev.port, 43 | open: config.dev.autoOpenBrowser, 44 | overlay: config.dev.errorOverlay 45 | ? { warnings: false, errors: true } 46 | : false, 47 | publicPath: config.dev.assetsPublicPath, 48 | proxy: config.dev.proxyTable, 49 | quiet: true, // necessary for FriendlyErrorsPlugin 50 | watchOptions: { 51 | poll: config.dev.poll 52 | } 53 | }, 54 | plugins: [ 55 | new webpack.DefinePlugin({ 56 | 'process.env': require('../config/dev.env') 57 | }), 58 | new webpack.HotModuleReplacementPlugin(), 59 | // https://github.com/ampedandwired/html-webpack-plugin 60 | new HtmlWebpackPlugin({ 61 | filename: 'index.html', 62 | template: 'index.html', 63 | inject: true, 64 | favicon: resolve('favicon.ico'), 65 | title: 'vue-element-admin' 66 | }) 67 | ] 68 | }) 69 | 70 | module.exports = new Promise((resolve, reject) => { 71 | portfinder.basePort = process.env.PORT || config.dev.port 72 | portfinder.getPort((err, port) => { 73 | if (err) { 74 | reject(err) 75 | } else { 76 | // publish the new Port, necessary for e2e tests 77 | process.env.PORT = port 78 | // add port to devServer config 79 | devWebpackConfig.devServer.port = port 80 | 81 | // Add FriendlyErrorsPlugin 82 | devWebpackConfig.plugins.push( 83 | new FriendlyErrorsPlugin({ 84 | compilationSuccessInfo: { 85 | messages: [ 86 | `Your application is running here: http://${ 87 | devWebpackConfig.devServer.host 88 | }:${port}` 89 | ] 90 | }, 91 | onErrors: config.dev.notifyOnErrors 92 | ? utils.createNotifierCallback() 93 | : undefined 94 | }) 95 | ) 96 | 97 | resolve(devWebpackConfig) 98 | } 99 | }) 100 | }) 101 | -------------------------------------------------------------------------------- /frontend/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const path = require('path') 3 | const utils = require('./utils') 4 | const webpack = require('webpack') 5 | const config = require('../config') 6 | const merge = require('webpack-merge') 7 | const baseWebpackConfig = require('./webpack.base.conf') 8 | const CopyWebpackPlugin = require('copy-webpack-plugin') 9 | const HtmlWebpackPlugin = require('html-webpack-plugin') 10 | const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') 11 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 12 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') 13 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin') 14 | 15 | function resolve(dir) { 16 | return path.join(__dirname, '..', dir) 17 | } 18 | 19 | const env = require('../config/prod.env') 20 | 21 | // For NamedChunksPlugin 22 | const seen = new Set() 23 | const nameLength = 4 24 | 25 | const webpackConfig = merge(baseWebpackConfig, { 26 | mode: 'production', 27 | module: { 28 | rules: utils.styleLoaders({ 29 | sourceMap: config.build.productionSourceMap, 30 | extract: true, 31 | usePostCSS: true 32 | }) 33 | }, 34 | devtool: config.build.productionSourceMap ? config.build.devtool : false, 35 | output: { 36 | path: config.build.assetsRoot, 37 | filename: utils.assetsPath('js/[name].[chunkhash:8].js'), 38 | chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].js') 39 | }, 40 | plugins: [ 41 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 42 | new webpack.DefinePlugin({ 43 | 'process.env': env 44 | }), 45 | // extract css into its own file 46 | new MiniCssExtractPlugin({ 47 | filename: utils.assetsPath('css/[name].[contenthash:8].css'), 48 | chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css') 49 | }), 50 | // generate dist index.html with correct asset hash for caching. 51 | // you can customize output by editing /index.html 52 | // see https://github.com/ampedandwired/html-webpack-plugin 53 | new HtmlWebpackPlugin({ 54 | filename: config.build.index, 55 | template: 'index.html', 56 | inject: true, 57 | favicon: resolve('favicon.ico'), 58 | title: 'cetus-gui', 59 | minify: { 60 | removeComments: true, 61 | collapseWhitespace: true, 62 | removeAttributeQuotes: true 63 | // more options: 64 | // https://github.com/kangax/html-minifier#options-quick-reference 65 | } 66 | // default sort mode uses toposort which cannot handle cyclic deps 67 | // in certain cases, and in webpack 4, chunk order in HTML doesn't 68 | // matter anyway 69 | }), 70 | new ScriptExtHtmlWebpackPlugin({ 71 | //`runtime` must same as runtimeChunk name. default is `runtime` 72 | inline: /runtime\..*\.js$/ 73 | }), 74 | // keep chunk.id stable when chunk has no name 75 | new webpack.NamedChunksPlugin(chunk => { 76 | if (chunk.name) { 77 | return chunk.name 78 | } 79 | const modules = Array.from(chunk.modulesIterable) 80 | if (modules.length > 1) { 81 | const hash = require('hash-sum') 82 | const joinedHash = hash(modules.map(m => m.id).join('_')) 83 | let len = nameLength 84 | while (seen.has(joinedHash.substr(0, len))) len++ 85 | seen.add(joinedHash.substr(0, len)) 86 | return `chunk-${joinedHash.substr(0, len)}` 87 | } else { 88 | return modules[0].id 89 | } 90 | }), 91 | // keep module.id stable when vender modules does not change 92 | new webpack.HashedModuleIdsPlugin(), 93 | // copy custom static assets 94 | new CopyWebpackPlugin([ 95 | { 96 | from: path.resolve(__dirname, '../static'), 97 | to: config.build.assetsSubDirectory, 98 | ignore: ['.*'] 99 | } 100 | ]) 101 | ], 102 | optimization: { 103 | splitChunks: { 104 | chunks: 'all', 105 | cacheGroups: { 106 | libs: { 107 | name: 'chunk-libs', 108 | test: /[\\/]node_modules[\\/]/, 109 | priority: 10, 110 | chunks: 'initial' // 只打包初始时依赖的第三方 111 | }, 112 | elementUI: { 113 | name: 'chunk-elementUI', // 单独将 elementUI 拆包 114 | priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app 115 | test: /[\\/]node_modules[\\/]element-ui[\\/]/ 116 | } 117 | } 118 | }, 119 | runtimeChunk: 'single', 120 | minimizer: [ 121 | new UglifyJsPlugin({ 122 | uglifyOptions: { 123 | mangle: { 124 | safari10: true 125 | } 126 | }, 127 | sourceMap: config.build.productionSourceMap, 128 | cache: true, 129 | parallel: true 130 | }), 131 | // Compress extracted CSS. We are using this plugin so that possible 132 | // duplicated CSS from different components can be deduped. 133 | new OptimizeCSSAssetsPlugin() 134 | ] 135 | } 136 | }) 137 | 138 | if (config.build.productionGzip) { 139 | const CompressionWebpackPlugin = require('compression-webpack-plugin') 140 | 141 | webpackConfig.plugins.push( 142 | new CompressionWebpackPlugin({ 143 | asset: '[path].gz[query]', 144 | algorithm: 'gzip', 145 | test: new RegExp( 146 | '\\.(' + config.build.productionGzipExtensions.join('|') + ')$' 147 | ), 148 | threshold: 10240, 149 | minRatio: 0.8 150 | }) 151 | ) 152 | } 153 | 154 | if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) { 155 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer') 156 | .BundleAnalyzerPlugin 157 | 158 | if (config.build.bundleAnalyzerReport) { 159 | webpackConfig.plugins.push( 160 | new BundleAnalyzerPlugin({ 161 | analyzerPort: 8080, 162 | generateStatsFile: false 163 | }) 164 | ) 165 | } 166 | 167 | if (config.build.generateAnalyzerReport) { 168 | webpackConfig.plugins.push( 169 | new BundleAnalyzerPlugin({ 170 | analyzerMode: 'static', 171 | reportFilename: 'bundle-report.html', 172 | openAnalyzer: false 173 | }) 174 | ) 175 | } 176 | } 177 | 178 | module.exports = webpackConfig 179 | -------------------------------------------------------------------------------- /frontend/config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"', 7 | // BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"', 8 | }) 9 | -------------------------------------------------------------------------------- /frontend/config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.2.6 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | // Paths 10 | assetsSubDirectory: 'static', 11 | assetsPublicPath: '/', 12 | proxyTable: { 13 | '/': { 14 | target:'http://127.0.0.1:8000', 15 | changeOrigin:true, 16 | secure: false, 17 | pathRewrite:{ 18 | '^/api': '/api' 19 | } 20 | } 21 | }, 22 | // Various Dev Server settings 23 | host: 'localhost', // can be overwritten by process.env.HOST 24 | port: 9528, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 25 | // autoOpenBrowser: true, 26 | autoOpenBrowser: false, 27 | errorOverlay: true, 28 | // notifyOnErrors: false, 29 | notifyOnErrors: true, 30 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 31 | 32 | // Use Eslint Loader? 33 | // If true, your code will be linted during bundling and 34 | // linting errors and warnings will be shown in the console. 35 | // useEslint: true, 36 | useEslint: false, 37 | // If true, eslint errors and warnings will also be shown in the error overlay 38 | // in the browser. 39 | showEslintErrorsInOverlay: false, 40 | 41 | /** 42 | * Source Maps 43 | */ 44 | 45 | // https://webpack.js.org/configuration/devtool/#development 46 | devtool: 'cheap-source-map', 47 | 48 | // CSS Sourcemaps off by default because relative paths are "buggy" 49 | // with this option, according to the CSS-Loader README 50 | // (https://github.com/webpack/css-loader#sourcemaps) 51 | // In our experience, they generally work as expected, 52 | // just be aware of this issue when enabling this option. 53 | cssSourceMap: false 54 | }, 55 | 56 | build: { 57 | // Template for index.html 58 | index: path.resolve(__dirname, '../dist/index.html'), 59 | 60 | // Paths 61 | assetsRoot: path.resolve(__dirname, '../dist'), 62 | assetsSubDirectory: 'static', 63 | 64 | /** 65 | * You can set by youself according to actual condition 66 | * You will need to set this if you plan to deploy your site under a sub path, 67 | * for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/, 68 | * then assetsPublicPath should be set to "/bar/". 69 | * In most cases please use '/' !!! 70 | */ 71 | assetsPublicPath: '/', 72 | 73 | /** 74 | * Source Maps 75 | */ 76 | 77 | productionSourceMap: false, 78 | // https://webpack.js.org/configuration/devtool/#production 79 | devtool: 'source-map', 80 | 81 | // Gzip off by default as many popular static hosts such as 82 | // Surge or Netlify already gzip all static assets for you. 83 | // Before setting to `true`, make sure to: 84 | // npm install --save-dev compression-webpack-plugin 85 | productionGzip: false, 86 | productionGzipExtensions: ['js', 'css'], 87 | 88 | // Run the build command with an extra argument to 89 | // View the bundle analyzer report after build finishes: 90 | // `npm run build --report` 91 | // Set to `true` or `false` to always turn it on or off 92 | bundleAnalyzerReport: process.env.npm_config_report || false, 93 | 94 | // `npm run build:prod --generate_report` 95 | generateAnalyzerReport: process.env.npm_config_generate_report || false 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /frontend/config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"', 4 | // BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"', 5 | } 6 | -------------------------------------------------------------------------------- /frontend/docs/HELP.md: -------------------------------------------------------------------------------- 1 | ## Cetus-GUI 帮助文档 2 | 3 | --- 4 | 5 | 此文档主要是帮助您解决Cetus-GUI安装和使用过程中可能会出现的问题。 6 | 7 | 目前项目处于测试阶段,希望您在使用时能积极向我们反馈bug和需求,我们将会很快的解决。 8 | 9 | --- 10 | 11 | ### 基础环境配置 12 | 13 | --- 14 | 15 | **所有与项目相关节点**确保有Python3环境。 16 | 17 | **所有节点**确保执行下列命令: 18 | 19 | * sudo yum install gcc gcc-c++ python3-devel python3-pip git 20 | * sudo pip3 install pymysql 21 | 22 | --- 23 | 24 | ### docker部署 25 | 26 | --- 27 | 28 | 此处是docker方式部署的配置方法,适用于简单配置Cetus-GUI环境的方式,源码安装请见源码部署一节。 29 | 30 | #### docker安装 31 | 32 | ``` 33 | # sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine 34 | # sudo yum install -y yum-utils device-mapper-persistent-data lvm2 35 | # sudo yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo 36 | # sudo yum makecache fast 37 | # sudo yum install docker-ce 38 | # sudo pip install -U docker-compose 39 | ``` 40 | 41 | #### 镜像部署 42 | 43 | 部署服务器的3306/4505/4506/8300/9527端口请务必不要占用! 44 | 45 | ``` 46 | # git clone https://github.com/Lede-Inc/Cetus-GUI 47 | # cd Cetus-GUI/backend/install 48 | # docker-compose up -d 49 | ``` 50 | 51 | #### SaltStack安装 52 | 53 | docker节点已经默认安装了salt-master,此处只需安装Minion节点即可,docker节点所在服务器也可以配置为Minion。 54 | 55 | * 安装 56 | 57 | ``` 58 | # sudo yum install https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm 59 | # sudo yum clean expire-cache 60 | # sudo yum install salt-minion 61 | ``` 62 | 63 | * 配置 64 | 65 | ``` 66 | # sudo vi /etc/salt/minion 67 | 68 | master: Master节点ip,此处填写docker节点所在宿主机的ip即可 69 | id: Minion唯一标识 70 | ``` 71 | 72 | * 启动 73 | 74 | ``` 75 | # sudo service salt-minion start 76 | ``` 77 | 78 | * 测试 79 | 80 | 在镜像内部执行,测试Minion是否配置成功。 81 | 82 | ``` 83 | # salt-key -A -y 84 | # salt-key -L 85 | # salt '*' test.ping 86 | ``` 87 | 88 | #### 网络配置 89 | 90 | 由于网络配置原因,需要修改部分配置信息。 91 | 92 | 为简化说明,我们假设镜像所在节点ip为10.0.0.1,Minion id为Minion1。待安装Cetus节点ip为10.0.0.2,Minion id为Minion2。 93 | 94 | * 镜像内部执行 95 | 96 | ``` 97 | # echo '10.0.0.1 Minion1' >> vi /etc/hosts 98 | # echo '10.0.0.2 Minion2' >> vi /etc/hosts 99 | ``` 100 | 101 | * 所有Minion节点执行 102 | 103 | ``` 104 | # echo '10.0.0.1 cetus_gui_db' >> vi /etc/hosts 105 | ``` 106 | 107 | #### 登陆 108 | 109 | http://localhost:9527 110 | 111 | --- 112 | 113 | ### 源码部署 114 | 115 | --- 116 | 117 | 源码部署适合于对项目进行大规模修改的情况,docker方式部署请跳过这一段。 118 | 119 | #### SaltStack安装 120 | 121 | 项目的应用依赖于配置好的SaltStack环境,请确保环境足够新以支持Python3 API。 122 | 123 | 以下是出现问题时可能的解决方案: 124 | 125 | * 安装 126 | 127 | Master节点: 128 | * 项目当前**必须**与Master节点位于同一个服务器 129 | * 安装流程 130 | * sudo yum install https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm 131 | * sudo yum clean expire-cache 132 | * sudo yum install salt-master 133 | * sudo yum install salt-minion 134 | 135 | Minion节点: 136 | * Master节点所在服务器也可以配置为Minion 137 | * 安装流程 138 | * sudo yum install https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm 139 | * sudo yum clean expire-cache 140 | * sudo yum install salt-minion 141 | 142 | * 配置 143 | 144 | Master节点: 145 | * 配置 146 | 147 | ``` 148 | # sudo vi /etc/salt/master 149 | 150 | file_roots: 151 | base: 152 | - $PATH/backend/shells # $PATH指项目所在路径 153 | ``` 154 | 155 | * 启动 156 | * sudo service salt-master start 157 | 158 | Minion节点: 159 | * 配置 160 | 161 | ``` 162 | # sudo vi /etc/salt/minion 163 | 164 | master: Master节点 165 | id: Minion唯一标识 166 | ``` 167 | 168 | * 启动 169 | * sudo service salt-minion start 170 | 171 | * 非root用户启动 172 | 173 | 在启动salt时可以修改启动用户,与整个项目的部署用户保持一致。**这一步是我们用非root用户部署项目时,必须要做的。** 174 | 175 | ``` 176 | # sudo vi /etc/salt/master 177 | 178 | user: user 179 | 180 | # 修改权限 181 | # sudo chown -R user:user /etc/salt /var/cache/salt /var/log/salt /var/run/salt 182 | 183 | # sudo service salt-master restart 184 | ``` 185 | 186 | Minion节点不需要修改,这样可以使发送到Minion的命令仍为root执行。 187 | 188 | * 其他问题 189 | 190 | 如果有salt命令执行时报编码错误,极有可能是调用了Python2下的salt命令,请删除Python2配置环境下的SaltStack并安装Python3版本。 191 | 192 | pip3 install salt 193 | 194 | #### 部署环境 195 | 196 | 部署环境上至少需要Python2和Python3双版本,需要**至少一个MySQL实例来放置项目数据库和Cetus配置数据库**。 197 | 198 | ``` 199 | git clone https://github.com/Lede-Inc/Cetus-GUI 200 | cd Cetus-GUI 201 | 202 | 修改如下配置: 203 | 204 | # Salt默认配置文件 205 | vi /etc/salt/master 206 | file_roots: 207 | base: 208 | - $PROJECT_PATH/Cetus-GUI/backend/shells 209 | 210 | # 修改Django配置文件 211 | vi backend/backend/settings.py 212 | DATABASES = { 213 | # 默认数据库,存放项目和Cetus信息 214 | 'default': { 215 | 'ENGINE': 'django.db.backends.mysql', 216 | 'NAME': 'xxx', 217 | 'USER': 'xxx', 218 | 'PASSWORD': 'xxx', 219 | 'HOST': 'xxx', 220 | 'PORT': xxx, 221 | }, 222 | # 存放Cetus远程配置库信息,可与默认数据库一致 223 | 'catalog': { 224 | 'user': 'xxx', 225 | 'password': 'xxx', 226 | 'host': 'xxx', 227 | 'port': xxx, 228 | } 229 | } 230 | # Cetus源代码路径 231 | CETUS_URL = 'https://github.com/Lede-Inc/cetus' 232 | # RabbitMQ配置端口 233 | BROKER_URL = 'amqp://guest@localhost:5672//' 234 | 235 | 修改后执行: 236 | sh deploy.sh 237 | ``` 238 | 239 | 以下是出现问题时可能的解决方案: 240 | 241 | * 更新项目代码 242 | 243 | ``` 244 | # git pull origin master 245 | # sh deploy.sh 246 | ``` 247 | 248 | * RabbitMQ问题 249 | 250 | * 可参考https://github.com/judasn/Linux-Tutorial/blob/master/markdown-file/RabbitMQ-Install-And-Settings.md 251 | 252 | * 端口占用 253 | 254 | 请确保以下端口未被占用 255 | * Django项目占用8000端口 256 | * Supervisor占用9001端口 257 | * SaltStack占用4505/4056端口 258 | * Vue项目占用9528端口 259 | 260 | * 部署情况查询 261 | 262 | ``` 263 | # supervisorctl 264 | backend RUNNING 265 | beat RUNNING 266 | celerycam RUNNING 267 | cetus RUNNING 268 | frontend RUNNING 269 | monitor RUNNING 270 | ``` 271 | 272 | 若有进程的状态非RUNNING,请查看deploy.sh的执行日志情况。 273 | 274 | #### 登陆 275 | 276 | http://localhost:9528 277 | 278 | --- 279 | 280 | ### 日志管理 281 | 282 | --- 283 | 284 | 在部署应用和安装配置Cetus过程中可能会存在各种报错,有些情况可能无法直接从网页端获取结果或解决方案,需要从后台日志中查询。 285 | 286 | 以下是应用程序和Cetus日志对应的位置。 287 | 288 | * 应用日志 289 | 290 | ``` 291 | cd $PATH/logs # $PATH指项目所在路径(docker的路径为/app) 292 | supervisor_backend.log # Django日志 293 | supervisor_beat.log 294 | supervisor_celerycam.log 295 | supervisor_cetus.log # 后台任务日志 296 | supervisord.log 297 | supervisor_frontend.log 298 | supervisor_monitor.log # Cetus监控日志 299 | ``` 300 | 301 | * Cetus日志 302 | 303 | ``` 304 | cd $CETUS_PATH/logs # $CETUS_PATH指Cetus项目所在路径,默认为/home/cetus_服务端口号 305 | cetus.log # 运行日志 306 | xa.log # XA事务日志 307 | slowquery.log # 慢日志 308 | ``` 309 | -------------------------------------------------------------------------------- /frontend/docs/img/cetus_command.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_command.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_config.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_fund_params.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_fund_params.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_info.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_install.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_list.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_monitor.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_task.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_user.png -------------------------------------------------------------------------------- /frontend/docs/img/cetus_vdb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/img/cetus_vdb.png -------------------------------------------------------------------------------- /frontend/docs/lededba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/docs/lededba.png -------------------------------------------------------------------------------- /frontend/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lede-Inc/Cetus-GUI/c58dcea37f23d0308170c465c5dee7db7209e7aa/frontend/favicon.ico -------------------------------------------------------------------------------- /frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |404啦
4 |正在返回首页...
5 |暂无监控信息
40 |