私はdjangoとawsで初心者です。私はawsで私のdjangoアプリケーションを実行しようとしています。このプロセスはビデオでいくつかのプロセスを作成し、このプロセスが表示されているユーザーが待機するように走っているので、ビデオサイズによっては約3分以上かかりますが、デベロッパーモードでは動作しましたが、awsでは一度2700ms後にプロセスが停止します。どのように私はawsでこのような長いタスクを実行することができますか?awsでdjango long taskを処理する方法
マイビュー:
######################### 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を使用していますか? – user602525
はい、弾力のある豆の豆を使用しています –