Exemplo n.º 1
0
    def post(self, request):
        if request.is_ajax():
            channel_name = request.POST.get('channel_name', None)
            try:
                data = Log.objects.get(channel=channel_name)
                if data.is_finished:
                    return JsonResponse({
                        'status':
                        False,
                        'message':
                        'Ssh terminal does not exist!'
                    })
                else:
                    data.end_time = now()
                    data.is_finished = True
                    data.save()

                    queue = get_redis_instance()
                    redis_channel = queue.pubsub()
                    queue.publish(channel_name, json.dumps(['close']))

                    return JsonResponse({
                        'status': True,
                        'message': 'Terminal has been killed !'
                    })
            except ObjectDoesNotExist:
                return JsonResponse({
                    'status': False,
                    'message': 'Request object does not exist!'
                })
Exemplo n.º 2
0
 def queue(self):
     """获取redis"""
     queue = get_redis_instance()
     channel = queue.pubsub()  #订阅
     return queue
Exemplo n.º 3
0
 def queue(self):
     queue = get_redis_instance()
     channel = queue.pubsub()
     return queue