2015-04-01 80 views
0

我想像Rails那样在Yii中设置资产编译和缩小。 http://www.yiiframework.com/doc-2.0/guide-structure-assets.html为什么Heroku看不到我部署后创建的文件?

我正在考虑使用PHP minifier。我宁愿不必手动编译并检入资产到Git中。然而,即使它工作,Heroku似乎也不会服务于不在Git中的新文件。为什么?

>heroku run bash 
Running `bash` attached to terminal... up, run.6857 
~ $ cd web 
cd web 
~/web $ ls 
ls 
MySample.php css   images   index.php robots.txt 
assets  favicon.ico index-test.php js 
~/web $ echo hello > hello.txt 
echo hello > hello.txt 
~/web $ cat hello.txt 
cat hello.txt 
hello 
~/web $ exit 
exit 
exit 

$ curl -I http://xxxxxx.herokuapp.com/hello.txt 
HTTP/1.1 404 Not Found 
+0

我已经知道Heroku使用临时文件系统。我不需要保存已编译的资产,因为它们可以在第一次请求时生成。 – Chloe 2015-04-01 23:39:31

回答

1

找不到hello.txt的原因是因为您的curl -I请求将由应用程序的新实例处理。为了演示,我可以在bash中删除我的index.php,但是当我使用curl -I来检索它时,我会得到200 OK。

$ heroku run bash 
Running `bash` attached to terminal... up, run.3070 
~ $ cd web 
~/web $ ls      
index.php 
~/web $ rm index.php  
~/web $ ls 
~/web $ curl -I http://xxxxx.herokuapp.com/index.php 
HTTP/1.1 200 OK 

另一种方式来证明这一点,开辟两个不同的bash的连接,然后运行的Heroku PS

$ heroku ps 
=== run: one-off processes 
run.3070 (1X): up 2015/04/01 19:30:07 (~ 37m ago): `bash` 
run.7783 (1X): up 2015/04/01 19:59:48 (~ 8m ago): `bash` 

这两个过程都不​​会共享内存短暂的。

+0

哦'heroku run'创建一个新实例...所以通过应用程序缩小资源并将它们保存到临时文件系统仍然可以工作,因为它们保存在正在运行的实例上。 – Chloe 2015-04-05 22:48:08