Can do nothing through Heroku shell

2019-07-21 08:10发布

I'm tying to deploy a django project to heroku.

First, I figure out that the staticfiles directory doesn't created automaticaly, or even when I run

$ heroku run python manage.py collectstatic --noinput

(no error is raised by the way). Until know it looks very similar to this question. Then I realized that I can't create any file or folder at all through the heroku shell.

For example:

$ heroku run mkdir EXAMPLE
Running `mkdir EXAMPLE` attached to terminal... up, run.7925
$ heroku run ls
Running `ls` attached to terminal... up, run.1406
total 32
BLAH BLAH BLAH NO EXAMPLE DIR HERE

Same goes with:

$ heroku run touch EXAMPLE.txt

On the other hand, when running:

$ heroku run bash

everything seems to look fine, even collectstatic. Files are collected, edited, created, whatever. But after exiting the bash terminal and running

$ heroku run ls

again it still shows the same problem, nothing changes.

Maybe I miss something...

Solution

Thanks to friism I've tried a different approach. Finally, the only necessary change was to change the Procfile to

web: python manage.py collectstatic --noinput; gunicorn app-name.wsgi

to force static collection.

Thanks again, Tom

1条回答
forever°为你锁心
2楼-- · 2019-07-21 08:45

Heroku dyno filesystems are ephemeral and changes are not persisted between dynos, nor across releases. Every time you do a heroku run, a new dyno is spun up for you. This is why you don't see changes persisted between runs.

Please see this note on the ephemeralness of dyno filesystems.

查看更多
登录 后发表回答