本文介绍了可以通过Heroku shell做任何事情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个django项目部署到heroku。



首先,我发现staticfiles目录不是自动创建的,甚至当我运行

  $ heroku运行python manage.py collectstatic --noinput 

(没有错误提出的方式)。直到知道它看起来非常相似于。然后我意识到我不能通过heroku shell创建任何文件或文件夹。



例如:

  $ heroku运行mkdir示例
运行`mkdir示例'附加到终端... up,run.7925
$ heroku运行ls
运行`ls`附加到终端... up,run.1406
共32
BLAH BLAH BLAH没有示例DIR here

相同:

  $ heroku运行触摸EXAMPLE.txt 

另一方面,运行时:

  $ heroku运行bash 

一切似乎看起来都很好,甚至收藏。文件被收集,编辑,创建,无论如何。但退出bash终端并运行

  $ heroku运行ls 

再次显示同样的问题,没有任何变化。



也许我想念某件事...



解决方案



感谢自己,我尝试了一种不同的方法。最后,唯一必要的改变是将Procfile更改为

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

强制静态收集。



再次感谢Tom

解决方案

Heroku dyno文件系统是短暂的,更改不会在dynos之间,也不会在版本之间。每次你执行一个 heroku运行,一个新的动力就会为你而生。这就是为什么你看不到运行之间持续变化的原因。



请参阅。


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

解决方案

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.

这篇关于可以通过Heroku shell做任何事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 03:52