mirror of https://github.com/openspug/spug
U api update
parent
9b6b191621
commit
94be8d2dff
|
@ -61,7 +61,7 @@ def _parse_params(request):
|
||||||
rds = get_redis_connection()
|
rds = get_redis_connection()
|
||||||
content = rds.get(api_token)
|
content = rds.get(api_token)
|
||||||
if content:
|
if content:
|
||||||
app_id, env_id = content.split(',')
|
app_id, env_id = content.decode().split(',')
|
||||||
app = App.objects.filter(pk=app_id).first()
|
app = App.objects.filter(pk=app_id).first()
|
||||||
else:
|
else:
|
||||||
api_key = AppSetting.get_default('api_key')
|
api_key = AppSetting.get_default('api_key')
|
||||||
|
|
|
@ -6,6 +6,7 @@ from concurrent import futures
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
import uuid
|
||||||
import os
|
import os
|
||||||
|
|
||||||
REPOS_DIR = settings.REPOS_DIR
|
REPOS_DIR = settings.REPOS_DIR
|
||||||
|
@ -14,9 +15,10 @@ REPOS_DIR = settings.REPOS_DIR
|
||||||
def deploy_dispatch(request, req, token):
|
def deploy_dispatch(request, req, token):
|
||||||
rds = get_redis_connection()
|
rds = get_redis_connection()
|
||||||
try:
|
try:
|
||||||
|
api_token = uuid.uuid4().hex
|
||||||
|
rds.setex(api_token, 60 * 60, f'{req.deploy.app_id},{req.deploy.env_id}')
|
||||||
helper = Helper(rds, token)
|
helper = Helper(rds, token)
|
||||||
helper.send_step('local', 1, f'完成\r\n{human_time()} 发布准备... ')
|
helper.send_step('local', 1, f'完成\r\n{human_time()} 发布准备... ')
|
||||||
rds.expire(token, 60 * 60)
|
|
||||||
env = AttrDict(
|
env = AttrDict(
|
||||||
SPUG_APP_NAME=req.deploy.app.name,
|
SPUG_APP_NAME=req.deploy.app.name,
|
||||||
SPUG_APP_ID=str(req.deploy.app_id),
|
SPUG_APP_ID=str(req.deploy.app_id),
|
||||||
|
@ -25,7 +27,8 @@ def deploy_dispatch(request, req, token):
|
||||||
SPUG_ENV_ID=str(req.deploy.env_id),
|
SPUG_ENV_ID=str(req.deploy.env_id),
|
||||||
SPUG_ENV_KEY=req.deploy.env.key,
|
SPUG_ENV_KEY=req.deploy.env.key,
|
||||||
SPUG_VERSION=req.version,
|
SPUG_VERSION=req.version,
|
||||||
SPUG_DEPLOY_TYPE=req.type
|
SPUG_DEPLOY_TYPE=req.type,
|
||||||
|
SPUG_API_TOKEN=api_token,
|
||||||
)
|
)
|
||||||
if req.deploy.extend == '1':
|
if req.deploy.extend == '1':
|
||||||
env.update(json.loads(req.deploy.extend_obj.custom_envs))
|
env.update(json.loads(req.deploy.extend_obj.custom_envs))
|
||||||
|
@ -37,6 +40,7 @@ def deploy_dispatch(request, req, token):
|
||||||
req.status = '-3'
|
req.status = '-3'
|
||||||
raise e
|
raise e
|
||||||
finally:
|
finally:
|
||||||
|
rds.expire(token, 5 * 60)
|
||||||
rds.close()
|
rds.close()
|
||||||
req.save()
|
req.save()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue