增加前端打包

This commit is contained in:
caoqianming 2022-06-07 11:52:32 +08:00
parent e096dd7ad3
commit a5f19641b6
4 changed files with 28 additions and 3 deletions

View File

@ -29,6 +29,13 @@ def reload_server_git():
return completed
@shared_task
def reload_client_git():
command = 'bash {}/git_client.sh'.format(SH_PATH)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed
@shared_task
def reload_server_only():
command = 'echo "{}" | sudo -S service supervisor reload'.format(SD_PWD)

View File

@ -1,11 +1,12 @@
from django.urls import path
from apps.develop.views import BackupDatabase, BackupMedia, ReloadServerGit, ReloadServerOnly
from apps.develop.views import BackupDatabase, BackupMedia, ReloadClientGit, ReloadServerGit, ReloadServerOnly
API_BASE_URL = 'api/develop/'
HTML_BASE_URL = 'develop/'
urlpatterns = [
path(API_BASE_URL + 'reload_server_git/', ReloadServerGit.as_view()),
path(API_BASE_URL + 'reload_client_git/', ReloadClientGit.as_view()),
path(API_BASE_URL + 'reload_server_only/', ReloadServerOnly.as_view()),
path(API_BASE_URL + 'backup_database/', BackupDatabase.as_view()),
path(API_BASE_URL + 'backup_media/', BackupMedia.as_view())

View File

@ -1,7 +1,7 @@
from rest_framework.views import APIView
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from apps.develop.tasks import backup_database, backup_media, reload_server_git, reload_server_only
from apps.develop.tasks import backup_database, backup_media, reload_client_git, reload_server_git, reload_server_only
from rest_framework.exceptions import APIException
# Create your views here.
@ -23,6 +23,23 @@ class ReloadServerGit(APIView):
raise APIException(completed.stdout)
class ReloadClientGit(APIView):
authentication_classes = []
permission_classes = []
def post(self, request):
"""
拉取前端代码并打包
拉取前端代码并打包
"""
completed = reload_client_git()
if completed.returncode == 0:
return Response()
else:
raise APIException(completed.stdout)
class ReloadServerOnly(APIView):
permission_classes = [IsAdminUser]

View File

@ -38,7 +38,7 @@ urlpatterns = [
# django后台
path('django/doc/', include('django.contrib.admindocs.urls')),
path('django/', admin.site.urls),
path('api-auth/', include('rest_framework.urls')),
path('django/api-auth/', include('rest_framework.urls')),
# api
path('', include('apps.auth1.urls')),