diff --git a/README.md b/README.md index 51b04aa..24c512e 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,16 @@ Spug是面向中小型企业设计的轻量级无Agent的自动化运维平台 - 使用文档:https://spug.cc/docs/about-spug/ - 更新日志:https://spug.cc/docs/change-log/ - 常见问题:https://spug.cc/docs/faq/ +- 推送助手:https://push.spug.cc ## 演示环境 演示地址:https://demo.spug.cc +## 🔥推送助手 + +推送助手是一个集成了电话、短信、邮件、飞书、钉钉、微信、企业微信等多通道的消息推送平台,用户只需要调用一个简单的URL,就可以完成多通道的消息推送,点击体验:[https://push.spug.cc](https://push.spug.cc) + ## 特性 @@ -39,9 +44,10 @@ Spug是面向中小型企业设计的轻量级无Agent的自动化运维平台 ## 安装 -[官方文档](https://spug.cc/docs/install/) +[官方文档](https://spug.cc/docs/install-docker) + +更多使用帮助请参考: [使用文档](https://spug.cc/docs/host-manage/) -更多使用帮助请参考 [使用文档](https://spug.cc/docs/host-manage/)。 ## 推荐项目 [Yearning — MYSQL 开源SQL语句审核平台](https://github.com/cookieY/Yearning) diff --git a/spug_api/apps/account/management/commands/user.py b/spug_api/apps/account/management/commands/user.py index 063794f..0d1be0f 100644 --- a/spug_api/apps/account/management/commands/user.py +++ b/spug_api/apps/account/management/commands/user.py @@ -52,10 +52,9 @@ class Command(BaseCommand): self.echo_error('缺少参数') self.print_help() user = User.objects.filter(username=options['u'], deleted_by_id__isnull=True).first() - if not user: - return self.echo_error(f'未找到登录名为【{options["u"]}】的账户') - user.is_active = True - user.save() + if user: + user.is_active = True + user.save() cache.delete(user.username) self.echo_success('账户已启用') elif action == 'reset': diff --git a/spug_api/apps/account/views.py b/spug_api/apps/account/views.py index b5542bc..085ed73 100644 --- a/spug_api/apps/account/views.py +++ b/spug_api/apps/account/views.py @@ -41,13 +41,12 @@ class UserView(AdminView): return json_response(error=f'已存在登录名为【{form.username}】的用户') role_ids, password = form.pop('role_ids'), form.pop('password') - if not verify_password(password): - return json_response(error='请设置至少8位包含数字、小写和大写字母的新密码') - if form.id: user = User.objects.get(pk=form.id) user.update_by_dict(form) else: + if not verify_password(password): + return json_response(error='请设置至少8位包含数字、小写和大写字母的新密码') user = User.objects.create( password_hash=User.make_password(password), created_by=request.user, diff --git a/spug_api/apps/apis/deploy.py b/spug_api/apps/apis/deploy.py index 7de92e7..1c96f60 100644 --- a/spug_api/apps/apis/deploy.py +++ b/spug_api/apps/apis/deploy.py @@ -6,6 +6,7 @@ from apps.setting.utils import AppSetting from apps.deploy.models import Deploy, DeployRequest from apps.repository.models import Repository from apps.deploy.utils import dispatch as deploy_dispatch +from libs.utils import human_datetime from threading import Thread import hashlib import hmac @@ -119,4 +120,7 @@ def _dispatch(deploy_id, ref, commit_id=None, message=None): req.save() if req.status == '2': + req.do_at = human_datetime() + req.do_by = deploy.created_by + req.save() deploy_dispatch(req) diff --git a/spug_api/apps/deploy/views.py b/spug_api/apps/deploy/views.py index 3665b85..e505eb7 100644 --- a/spug_api/apps/deploy/views.py +++ b/spug_api/apps/deploy/views.py @@ -130,6 +130,10 @@ class RequestDetailView(View): outputs[item['key']]['status'] = item['status'] data = rds.lrange(key, counter, counter + 9) response['index'] = counter + if counter == 0: + for item in outputs: + outputs[item]['data'] += '\r\n\r\n未读取到数据,Spug 仅保存最近2周的日志信息。' + if req.is_quick_deploy: if outputs['local']['data']: outputs['local']['data'] = f'{human_time()} 读取数据... ' + outputs['local']['data'] diff --git a/spug_api/apps/host/models.py b/spug_api/apps/host/models.py index 6845976..3726994 100644 --- a/spug_api/apps/host/models.py +++ b/spug_api/apps/host/models.py @@ -84,7 +84,7 @@ class HostExtend(models.Model, ModelMixin): class Group(models.Model, ModelMixin): - name = models.CharField(max_length=20) + name = models.CharField(max_length=50) parent_id = models.IntegerField(default=0) sort_id = models.IntegerField(default=0) hosts = models.ManyToManyField(Host, related_name='groups') diff --git a/spug_api/apps/host/utils.py b/spug_api/apps/host/utils.py index 097f201..feab7d5 100644 --- a/spug_api/apps/host/utils.py +++ b/spug_api/apps/host/utils.py @@ -202,6 +202,8 @@ def fetch_host_extend(ssh): code, out = ssh.exec_command_raw('hostname -I') if code == 0: for ip in out.strip().split(): + if len(ip) > 15: # ignore ipv6 + continue if ipaddress.ip_address(ip).is_global: if len(public_ip_address) < 10: public_ip_address.add(ip) diff --git a/spug_api/apps/monitor/views.py b/spug_api/apps/monitor/views.py index 59f0705..bf5b11e 100644 --- a/spug_api/apps/monitor/views.py +++ b/spug_api/apps/monitor/views.py @@ -114,6 +114,7 @@ def get_overview(request): for item in Detection.objects.all(): data = {} for key in json.loads(item.targets): + key = str(key) data[key] = { 'id': f'{item.id}_{key}', 'group': item.group, diff --git a/spug_api/apps/schedule/builtin.py b/spug_api/apps/schedule/builtin.py index 54effa2..a4bd8d3 100644 --- a/spug_api/apps/schedule/builtin.py +++ b/spug_api/apps/schedule/builtin.py @@ -6,6 +6,7 @@ from apps.account.models import History from apps.alarm.models import Alarm from apps.schedule.models import Task, History as TaskHistory from apps.deploy.models import DeployRequest +from apps.app.models import DeployExtend1 from apps.exec.models import ExecHistory from apps.notify.models import Notify from apps.deploy.utils import dispatch @@ -21,6 +22,12 @@ def auto_run_by_day(): History.objects.filter(created_at__lt=date_30).delete() Notify.objects.filter(created_at__lt=date_7, unread=False).delete() Alarm.objects.filter(created_at__lt=date_30).delete() + for item in DeployExtend1.objects.all(): + index = 0 + for req in DeployRequest.objects.filter(deploy_id=item.deploy_id, repository_id__isnull=False): + if index > item.versions and req.repository_id: + req.repository.delete() + index += 1 try: record = ExecHistory.objects.all()[50] ExecHistory.objects.filter(id__lt=record.id).delete() diff --git a/spug_api/spug/settings.py b/spug_api/spug/settings.py index a22d364..1830955 100644 --- a/spug_api/spug/settings.py +++ b/spug_api/spug/settings.py @@ -131,7 +131,7 @@ AUTHENTICATION_EXCLUDES = ( re.compile('/apis/.*'), ) -SPUG_VERSION = 'v3.1.5' +SPUG_VERSION = 'v3.1.7' # override default config try: diff --git a/spug_web/src/libs/index.js b/spug_web/src/libs/index.js index 77c8bba..e360462 100644 --- a/spug_web/src/libs/index.js +++ b/spug_web/src/libs/index.js @@ -10,4 +10,4 @@ export * from './functools'; export * from './router'; export const http = _http; export const history = _history; -export const VERSION = 'v3.1.5'; +export const VERSION = 'v3.1.7'; diff --git a/spug_web/src/pages/deploy/app/Ext1Setup3.js b/spug_web/src/pages/deploy/app/Ext1Setup3.js index 7a96caa..cead84c 100644 --- a/spug_web/src/pages/deploy/app/Ext1Setup3.js +++ b/spug_web/src/pages/deploy/app/Ext1Setup3.js @@ -46,7 +46,7 @@ export default observer(function () {