プログラミング学習日記

プログラミング学習時のメモ帳。

herokuのチュートリアル9

間違っている場所あったら優しく教えてね

herokuのチュートリアル9

herokuチュートリアル

今回はlocal環境でherokuを動かしてみようというもの

$ python manage.py collectstatic

先にmanage.pyの中身を確認する

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gettingstarted.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

とりあえず実行する

$ python manage.py collectstatic
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

django.core.managementのモジュールが無いよとエラーが吐かれてしまった.

$ pip list
Django 2.1.7

しっかりインストールされていることがわかる
python3系で実行してみる

$ python3 manage.py collectstatic
120 static files copied to '/Users/******/python-getting-started/staticfiles', 363 post-processed.

なんか知らんけどコピーされたみたいです.

python3 manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    /Users/******/python-getting-started/staticfiles

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel:

もう一度実行してみることにするとこうなりました.
すでに存在するけど上書きしていいですか?
yesを押してみます

Type 'yes' to continue, or 'no' to cancel: yes

0 static files copied to '/Users/*****/python-getting-started/staticfiles', 120 unmodified, 256 post-processed.

ではlocal環境で動かしてみよう

$ heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
03:03:38 web.1   |  [2019-03-27 03:03:38 +0900] [36537] [INFO] Starting gunicorn 19.9.0
03:03:38 web.1   |  [2019-03-27 03:03:38 +0900] [36537] [INFO] Listening at: http://0.0.0.0:5000 (36537)
03:03:38 web.1   |  [2019-03-27 03:03:38 +0900] [36537] [INFO] Using worker: sync
03:03:38 web.1   |  [2019-03-27 03:03:38 +0900] [36540] [INFO] Booting worker with pid: 36540
03:04:23 web.1   |  [2019-03-27 03:04:23 +0900] [36537] [INFO] Handling signal: winch
03:04:23 web.1   |  [2019-03-27 03:04:23 +0900] [36537] [INFO] Handling signal: winch
03:04:23 web.1   |  [2019-03-27 03:04:23 +0900] [36537] [INFO] Handling signal: winch
03:04:23 web.1   |  [2019-03-27 03:04:23 +0900] [36537] [INFO] Handling signal: winch

この後マウスを動かすたびにターミナル上でHandling signalの履歴がどんどん表示されていったので成功したとみられる.
Ctrl + C で操作を終了した.

ブログを見ていただきありがとうございました