{"id":455,"date":"2015-07-02T23:06:07","date_gmt":"2015-07-02T14:06:07","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2015\/07\/02\/djangoaws_elasticbeanstalk\/"},"modified":"2015-07-02T23:06:07","modified_gmt":"2015-07-02T14:06:07","slug":"djangoaws_elasticbeanstalk","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2015\/07\/02\/djangoaws_elasticbeanstalk\/","title":{"rendered":"Django\u3067\u30d0\u30c3\u30c1\u51e6\u7406\u3092\u884c\u3046(AWS Elasticbeanstalk)"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/05\/aws_elastic_beanstalk_django_centos65_pydev1_django\" target=\"_blank\">(1) Django\u8d77\u52d5\u307e\u3067<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/05\/aws_elastic_beanstalk_django_centos65_pydev2_tips_sshrds\" target=\"_blank\">(2) (TIPS) SSH\u3001RDS\u3078\u306e\u63a5\u7d9a<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/05\/aws_elastic_beanstalk_django_centos65_pydev3_tips\" target=\"_blank\">(3) (TIPS) \u30ed\u30b0\u306e\u78ba\u8a8d\u3068\u30c7\u30d7\u30ed\u30a4\u7d50\u679c\u306e\u78ba\u8a8d<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/05\/aws_elastic_beanstalk_django_centos65_pydev4\" target=\"_blank\">(4) \u3044\u304f\u3064\u304b\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c8<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/05\/aws_elastic_beanstalk_django_centos65_pydev5\" target=\"_blank\">(5) \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/06\/aws_elastic_beanstalk_django_centos65_pydev6_createadmin\" target=\"_blank\">(6) createadmin \u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c8<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/31\/aws_elastic_beanstalk_django_7_ipdns\" target=\"_blank\">(7) \u9759\u7684IP\u30a2\u30c9\u30ec\u30b9\u306e\u8a2d\u5b9a\u3068\u30c9\u30e1\u30a4\u30f3\u306e\u53d6\u5f97\u3068DNS\u306e\u8a2d\u5b9a<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/05\/20\/aws_elastic_beanstalk_rds_utf-8\" target=\"_blank\">AWS Elastic Beanstalk RDS \u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092utf-8\u306b\u8a2d\u5b9a\u3057\u306a\u304a\u3059<\/a><\/li>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/07\/02\/djangoaws_elasticbeanstalk\" target=\"_blank\">Django\u3067\u30d0\u30c3\u30c1\u51e6\u7406\u3092\u884c\u3046(AWS Elasticbeanstalk)<\/a><\/li>\n<\/ul>\n<h2>1.Django\u3067\u30d0\u30c3\u30c1\u3092\u52d5\u304b\u3059<\/h2>\n<p><a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/B00P8DQZY4\/ref=as_li_ss_il?ie=UTF8&amp;camp=247&amp;creative=7399&amp;creativeASIN=B00P8DQZY4&amp;linkCode=as2&amp;tag=typea09-22\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=B00P8DQZY4&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" \/><\/a><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border-style: none !important;\" border=\"0\" alt=\"\" src=\"http:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=as2&amp;o=9&amp;a=B00P8DQZY4\" width=\"1\" height=\"1\" \/><\/p>\n<p>django-kronos \u3092\u4f7f\u3063\u3066\u6975\u3081\u3066\u7c21\u5358\u306b\u5b9f\u73fe\u3067\u304d\u305f\u3002<\/p>\n<p><a title=\"https:\/\/github.com\/jgorset\/django-kronos\" href=\"https:\/\/github.com\/jgorset\/django-kronos\">https:\/\/github.com\/jgorset\/django-kronos<\/a><\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30eb\u30fc\u30c8\u3082\u3057\u304f\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u3042\u308b\u3001cron \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u81ea\u52d5\u3067\u8aad\u307f\u8fbc\u3093\u3067\u304f\u308c\u308b\u3002<\/p>\n<p>\u8a66\u3057\u306b1\u6642\u9593\u6bce\u306b\u30e1\u30fc\u30eb\u3092\u9001\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u66f8\u3044\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">import kronos\r\nfrom phraseit.service import mail\r\n \r\n@kronos.register('0 * * * *')\r\ndef my_method():\r\n    message = r'this is kronos test mail'\r\n    mail.send_mail('Hiroto Yagi', 'pppiroto@gmail.com', 'krons test', message)<\/pre>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/06\/26\/centospython\">\u30e1\u30fc\u30eb\u9001\u4fe1\u90e8\u5206\u306f\u3001\u5148\u65e5\u4f5c\u6210\u3057\u305f\u3082\u306e\u3002<\/a><\/p>\n<p>\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u304c\u3001<a href=\"http:\/\/djangoproject.jp\/doc\/ja\/1.0\/howto\/custom-management-commands.html\">Django management commands<\/a> \u3067\u3082\u540c\u69d8\u306b\u4f7f\u3048\u308b\u3089\u3057\u3044\u3002<\/p>\n<p>\u3055\u3066\u3001\u52d5\u4f5c\u539f\u7406\u3068\u3057\u3066\u306f\u3001cron \u306b \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5b9f\u884c\u3092\u767b\u9332\u3059\u308b\u3082\u306e\u307f\u305f\u3044\u306a\u306e\u3067\u3001Windows \u3067\u306f\u305d\u306e\u307e\u307e\u52d5\u304b\u306a\u3044\u3002<\/p>\n<p><a href=\"http:\/\/typea.info\/blg\/glob\/aws-elastic-beanstalk\/\">\u4e00\u5ea6 AWS Elasticbeanstalk \u306b\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u307f\u308b\u3002<\/a><\/p>\n<h2>2.\u767b\u9332\u30bf\u30b9\u30af\u306e\u30ea\u30b9\u30c8<\/h2>\n<h3>2.1 VirtualEnv \u306e\u958b\u59cb<\/h3>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2015\/01\/05\/aws_elastic_beanstalk_django_centos65_pydev2_tips_sshrds\">EC2\u306bSSH\u3067\u30ed\u30b0\u30a4\u30f3<\/a>\u3057\u3001root\u306b\u306a\u3063\u305f\u4e0a\u3067\u3001VirtualEnv \u3092\u8d77\u52d5\u3002<\/p>\n<pre class=\"prettyprint linenums\">Last login: Tue Jun 30 13:27:52 2015 from 14-132-74-50.aichieast1.commufa.jp\r\n _____ _           _   _      ____                       _        _ _\r\n| ____| | __ _ ___| |_(_) ___| __ )  ___  __ _ _ __  ___| |_ __ _| | | __\r\n|  _| | |\/ _` \/ __| __| |\/ __|  _ \\ \/ _ \\\/ _` | '_ \\\/ __| __\/ _` | | |\/ \/\r\n| |___| | (_| \\__ \\ |_| | (__| |_) |  __\/ (_| | | | \\__ \\ || (_| | |   &lt;\r\n|_____|_|\\__,_|___\/\\__|_|\\___|____\/ \\___|\\__,_|_| |_|___\/\\__\\__,_|_|_|\\_\\\r\n                                       Amazon Linux AMI\r\n\r\nThis EC2 instance is managed by AWS Elastic Beanstalk. Changes made via SSH\r\nWILL BE LOST if the instance is replaced by auto-scaling. For more information\r\non customizing your Elastic Beanstalk environment, see our documentation here:\r\nhttp:\/\/docs.aws.amazon.com\/elasticbeanstalk\/latest\/dg\/customize-containers-ec2.html\r\n[ec2-user@ip-172-31-30-53 ~]$ cd \/opt\/python\/run\/venv\/bin\r\n[ec2-user@ip-172-31-30-53 bin]$ sudo su\r\n[root@ip-172-31-30-53 bin]# . activate\r\n(venv)[root@ip-172-31-30-53 bin]# <\/pre>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30d7\u30ed\u30a4\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057\u3001python manage.py showtasks<\/p>\n<pre class=\"prettyprint linenums\">(venv)[root@ip-172-31-30-53 bin]# cd \/opt\/python\/current\/app\r\n(venv)[root@ip-172-31-30-53 app]# python manage.py showtasks\r\n* List of tasks registered in Kronos *\r\n&gt;&gt; Kronos tasks\r\n    &gt;&gt; my_method\r\n&gt;&gt; Django tasks<\/pre>\n<p>\u30bf\u30b9\u30af\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308b\u3002<\/p>\n<h3>2.2 cron \u306b\u767b\u9332<\/h3>\n<p>\u3053\u308c\u3060\u3051\u3067\u306f\u3001\u52d5\u3044\u3066\u304f\u308c\u306a\u3044\u306e\u3067\u3001cron\u306b\u767b\u9332\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">(venv)[root@ip-172-31-30-53 app]# python manage.py installtasks\r\nInstalled 1 tasks.<\/pre>\n<p>\u78ba\u8a8d<\/p>\n<pre class=\"prettyprint linenums\">(venv)[root@ip-172-31-30-53 app]# crontab -l\r\n0 * * * * \/opt\/python\/run\/venv\/bin\/python \/opt\/python\/bundle\/47\/app\/manage.py runtask my_method  --settings=phraseit.settings  $KRONOS_BREAD_CRUMB<\/pre>\n<p>root \u3067\u767b\u9332\u3059\u308b\u306e\u304c\u59a5\u5f53\u304b\u3069\u3046\u304b\u308f\u304b\u3089\u306a\u3044\u304c\u3001root \u3067\u3084\u3089\u306a\u3044\u3068\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u306e\u3067\u5b89\u6613\u306a\u65b9\u6cd5\u3092\u9078\u3076\u3002<\/p>\n<h3>2.3 \u30e1\u30fc\u30eb\u304c\u4e00\u6642\u9593\u6bce\u306b\u5c4a\u304f<\/h3>\n<p><a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4774174041\/ref=as_li_ss_il?ie=UTF8&amp;camp=247&amp;creative=7399&amp;creativeASIN=4774174041&amp;linkCode=as2&amp;tag=typea09-22\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4774174041&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" \/><\/a><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border-style: none !important;\" border=\"0\" alt=\"\" src=\"http:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=as2&amp;o=9&amp;a=4774174041\" width=\"1\" height=\"1\" \/><\/p>\n<p>\u4ed5\u4e8b\u4e2d\u306b\u3082\u304d\u3063\u3061\u308a\u6bce\u66420\u5206\u306b\u30e1\u30fc\u30eb\u304c\u5c4a\u3044\u305f\u3002OKOK\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/9f281ae01de5_13E26\/mail_per_hour.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"mail_per_hour\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;\" border=\"0\" alt=\"mail_per_hour\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/9f281ae01de5_13E26\/mail_per_hour_thumb.jpg\" width=\"345\" height=\"224\" \/><\/a><\/p>\n<h3>2.4 cron\u30bf\u30b9\u30af\u306e\u89e3\u9664<\/h3>\n<p>\u52d5\u4f5c\u78ba\u8a8d\u306f\u3068\u308c\u305f\u3002\u3053\u306e\u307e\u307e\u3060\u3068\u304b\u306a\u308a\u3046\u3063\u3068\u304a\u3057\u3044\u306e\u3067\u3001cron\u30bf\u30b9\u30af\u3092\u89e3\u9664\u3057\u3066\u304a\u304f\u3002<\/p>\n<pre class=\"prettyprint linenums\">(venv)[root@ip-172-31-30-53 app]# crontab -r\r\n(venv)[root@ip-172-31-30-53 app]# crontab -l\r\nno crontab for root<\/pre>\n<p>\u30e1\u30fc\u30eb\u98db\u3070\u306a\u304f\u306a\u3063\u305f\u3002OK\uff01<\/p>\n<p><a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4873111951\/ref=as_li_ss_il?ie=UTF8&amp;camp=247&amp;creative=7399&amp;creativeASIN=4873111951&amp;linkCode=as2&amp;tag=typea09-22\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4873111951&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" \/><\/a><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border-style: none !important;\" border=\"0\" alt=\"\" src=\"http:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=as2&amp;o=9&amp;a=4873111951\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>(1) Django\u8d77\u52d5\u307e\u3067 (2) (TIPS) SSH\u3001RDS\u3078\u306e\u63a5\u7d9a (3) (TIPS) \u30ed\u30b0\u306e\u78ba\u8a8d\u3068\u30c7\u30d7\u30ed\u30a4\u7d50\u679c\u306e\u78ba\u8a8d (4) \u3044\u304f\u3064\u304b\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c8 (5) \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210 (6) createa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[79,80,29,20],"tags":[],"class_list":["post-455","post","type-post","status-publish","format-standard","hentry","category-aws-ec2","category-aws-elastic-beanstalk","category-django","category-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=455"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/455\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}