【问题标题】:collectstatic throws 'OSError: [Errno 2] No such file or directory:' on dotcloudcollectstatic 在 dotcloud 上抛出 'OSError: [Errno 2] No such file or directory:'
【发布时间】:2012-09-01 11:41:38
【问题描述】:

按照dotcloud教程中的说明,这是我postinstall中的代码:

#!/bin/sh  
python createdb.py  
python some_project/manage.py syncdb --noinput
python mkadmin.py
mkdir -p /home/dotcloud/data/media /home/dotcloud/volatile/static
ln -sf /home/dotcloud/volatile/static /home/dotcloud/static
python some_project/manage.py collectstatic --noinput  

...nginx.conf

location /media/ { root /home/dotcloud/data ; }

...和settings.py

....
MEDIA_ROOT = '/home/dotcloud/data/media/'

MEDIA_URL = '/media/'

STATIC_ROOT = '/home/dotcloud/volatile/static/'

STATIC_URL = '/static/'

....

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'some_project',
)  

postinstall 运行时,抛出此错误:
OSError: [Errno 2] No such file or directory: '/home/dotcloud/rsync-1346498181296/some_project/static'

我已经使用它很长时间了,它令人困惑,因为文档说 /static/ 已经由 python 服务设置并链接到 /home/dotcloud/static

有人可以帮忙吗?在我开始为静态内容设置应用程序之前,一切都运行良好。 Django 版本是 Python 2.7 上的 1.4.1

【问题讨论】:

    标签: django dotcloud


    【解决方案1】:

    睡了一会儿后,我发现我的“静态”文件夹不在我在“settings.py”文件中指定的位置。

    此外,dotCloud 更新了他们的文档,警告“/static/”不再像前面所说的那样自动创建,所以我更改了我的postinstall 脚本以删除符号链接到“/static/”并调整了@987654324 @ 文件按照更新文档中的说明进行。

    参考:
    Handlinng static files on dotCloud

    【讨论】:

    • 嗨,我是 django+dotcom 新手,尝试根据最新文档设置静态:docs.dotcloud.com/0.9/tutorials/python/django/…。我也得到 22:33:43.553537: [www.0] OSError: [Errno 2] No such file or directory: '/home/dotcloud/rsync-1360362707945/static' 需要对给定的配置进行任何更改在本教程中?
    【解决方案2】:

    任何像“./postinstall failed with return code”这样的错误消息都意味着您自己的脚本有问题,而不是平台。

    为了在 dotCloud 上轻松调试安装后执行,您可以执行以下操作:

    假设您的应用是“拉面”,而您的服务是“www”。

    $ dotcloud -A ramen run www
    > ~/current/postinstall
    

    它将重新执行安装后,但这次从您的会话开始,因此您可以轻松更新安装后代码并重新运行它,而无需一次又一次地推送。

    找到根本原因后,在本地修复它并重新推送您的应用程序。

    【讨论】:

      猜你喜欢
      • 2016-06-07
      • 2017-07-05
      • 2018-11-20
      • 2018-07-24
      • 1970-01-01
      • 2019-03-25
      • 2018-01-21
      • 1970-01-01
      • 2015-05-06
      相关资源
      最近更新 更多