【发布时间】:2017-08-03 19:57:34
【问题描述】:
我是 django 和 aws 的初学者,我正在尝试在 aws 上运行我的 django 应用程序,我有这个视图可以在视频上制作一些进程并在此进程运行时显示加载模板以使用户等待,所以根据视频大小,大约需要 3 分钟或更长时间,它确实在开发模式下工作,但是一旦在 aws 上,该过程在最多 2700 毫秒后停止。我怎么能在 aws 上运行这么长的任务?
我的看法:
######################### Call load template ###############################
def process(request):
return render(request, 'testgif.html')
######################### Process the video and send notification email to user when process is done ###################################
def getor(request):
# get video from s3 bucket mounted on ec2 instance
var = Video.objects.order_by('id').last()
v = '/mnt/s3/media/videos/' + str(var)
# process
subprocess.call("./step1.sh %s" % (str(v)), shell=True)
#send email notification
current_site = get_current_site(request)
user = User.objects.values('username').order_by('id').last()
us = user['username']
subject = 'Notification of end of process.'
message = render_to_string('notify.html', {
'us':us,
'domain':current_site.domain,
})
eml = User.objects.values('email').order_by('id').last()
toemail = eml['email']
email = EmailMessage(subject, message, to=[toemail])
email.send()
return render(request, 'endexecut.html')
我的加载模板:
{% extends 'base.html' %}
{% load staticfiles %}
{% block content %}
<div class="container">
<div class="row">
<div class="jumbotron">
<div class="row">
<center>
<p> Please wait, your video is processing ! </p>
<img src="{% static "images/loading1.gif" %}" id="image-id" width="600" height="400" />
</center>
</div>
</div>
</div>
</div>
{% endblock %}
{% block javascript %}
<script type="text/javascript">
$.ajax({
url: '/wmark/',
type: 'GET',
dataType: 'html',
success: function(result){
$('#image-id').attr('src', result.image);
$('.container').html(result);
},
error: function(xhr){
alert(xhr.responseText); //Remove this when all is fine.
}
});
</script>
{% endblock %}
【问题讨论】:
-
它是如何部署的,只是一个 ec2 实例还是您使用的是弹性 beanstalk?
-
是的,我正在使用弹性豆茎
标签: django amazon-web-services amazon-ec2