无法使用Cloud Foundry push

时间:2019-02-25 16:48:07

标签: python django cloudfoundry pivotal-cloud-foundry buildpack

我习惯于将Spring应用程序推送到Cloud Foundry。这是我第一次推送Django应用。上传完成后,它显示:

> Waiting for app to start...
Start unsuccessful

我的应用程序项目结构如下:

.gitignore
Procfile
README.md
/app
    __init__.py
    settings.py
    urls.py
    wsgi.py
/assets
    __init__.py
    admin.py
    apps.py
    data_generator.py
    models.py
    tests.py
    urls.py
    views.py
    /migrations
        __init__.py
/tokentype
    __init__.py
    admin.py
    apps.py
    models.py
    tests.py
    urls.py
    views.py
    /migrations
        __init__.py
db.sqlite3
log_storage.log
manage.py
manifest.yml
/repo
    assetmanagement-3.9-py3-none-any.whl
    mindsphere_core-0.1.0-py3-none-any.whl
requirements.txt
runtime.txt
sdk_util.py
  • 我的runtime.txt包含python-3.5.x
  • 我的Procfile包含web: python manage.py migrate && python manage.py runserver
  • 我的requirements.txt具有所有必需的要求,包括Django和djangorestframework。
  • 并且manifest.yaml具有以下内容:

    applications:
    - name: pythondemoapp
      instances: 1
      randon-route : true
      path: .
      memory: 1GB
      env:
        HOST_ENVIRONMENT: eu1-int
    

在应用无法启动后运行cf logs pythondemoapp --recent时,出现以下日志,其中抱怨了几个问题:

  • ModuleNotFoundError: No module named 'django' (but I have this in my requirements.txt)
  • Failed to make TCP connection to port 8080: connection refused.(我无法理解为什么它在http://127.0.0.1:8000/处(即本地主机)启动开发服务器)
  • AttributeError: module 'pip._internal' has no attribute 'utils'

请查看日志:

       2019-02-25T21:14:52.28+0530 [API/1] OUT Updated app with guid 364c5cd1-63a3-43a2-b854-23ddd751099f ({"buildpack"=>"", "disk_quota"=>512, "environment_json"=>"[PRIVATE DATA HIDDEN]", "health_check_http_endpoint"=>"", "health_check_type"=>"port", "instances"=>1, "memory"=>1024, "name"=>"pythondemoapp", "space_guid"=>"3e84ef99-bf0a-4d76-897f-ddc5948a7ca1"})
       2019-02-25T21:14:53.24+0530 [API/1] OUT Uploading bits for app with guid 364c5cd1-63a3-43a2-b854-23ddd751099f
       2019-02-25T21:15:02.99+0530 [API/1] OUT Updated app with guid 364c5cd1-63a3-43a2-b854-23ddd751099f ({"state"=>"STOPPED"})
       2019-02-25T21:15:03.41+0530 [API/0] OUT Creating build for app with guid 364c5cd1-63a3-43a2-b854-23ddd751099f
       2019-02-25T21:15:04.07+0530 [API/0] OUT Updated app with guid 364c5cd1-63a3-43a2-b854-23ddd751099f ({"state"=>"STARTED"})
       2019-02-25T21:15:04.09+0530 [STG/0] OUT Downloading stratos...
       2019-02-25T21:15:04.09+0530 [STG/0] OUT Downloading nodejs_buildpack_deprecated...
       2019-02-25T21:15:04.09+0530 [STG/0] OUT Downloading ruby_buildpack...
       2019-02-25T21:15:04.09+0530 [STG/0] OUT Downloading python_buildpack...
       2019-02-25T21:15:04.09+0530 [STG/0] OUT Downloading php_buildpack...
       2019-02-25T21:15:04.12+0530 [STG/0] OUT Downloaded ruby_buildpack
       2019-02-25T21:15:04.12+0530 [STG/0] OUT Downloading staticfile_buildpack...
       2019-02-25T21:15:04.12+0530 [STG/0] OUT Downloaded stratos
       2019-02-25T21:15:04.12+0530 [STG/0] OUT Downloading mendix_buildpack...
       2019-02-25T21:15:04.13+0530 [STG/0] OUT Downloaded python_buildpack
       2019-02-25T21:15:04.13+0530 [STG/0] OUT Downloading go_buildpack...
       2019-02-25T21:15:04.13+0530 [STG/0] OUT Downloaded php_buildpack
       2019-02-25T21:15:04.14+0530 [STG/0] OUT Downloading dotnet_core_buildpack...
       2019-02-25T21:15:04.15+0530 [STG/0] OUT Downloaded mendix_buildpack
       2019-02-25T21:15:04.15+0530 [STG/0] OUT Downloading nodejs_buildpack...
       2019-02-25T21:15:04.15+0530 [STG/0] OUT Downloaded staticfile_buildpack
       2019-02-25T21:15:04.15+0530 [STG/0] OUT Downloading java_buildpack...
       2019-02-25T21:15:04.16+0530 [STG/0] OUT Downloaded go_buildpack
       2019-02-25T21:15:04.18+0530 [STG/0] OUT Downloaded dotnet_core_buildpack
       2019-02-25T21:15:04.19+0530 [STG/0] OUT Downloaded java_buildpack
       2019-02-25T21:15:05.18+0530 [STG/0] OUT Downloaded nodejs_buildpack
       2019-02-25T21:15:05.18+0530 [STG/0] OUT Downloaded nodejs_buildpack_deprecated
       2019-02-25T21:15:05.19+0530 [STG/0] OUT Cell fefe8742-9a99-4e6c-b773-034414c67b95 creating container for instance b1aaa9db-288e-4a97-b7ae-38b71b82f150
       2019-02-25T21:15:08.00+0530 [STG/0] OUT Cell fefe8742-9a99-4e6c-b773-034414c67b95 successfully created container for instance b1aaa9db-288e-4a97-b7ae-38b71b82f150
       2019-02-25T21:15:08.33+0530 [STG/0] OUT Downloading app package...
       2019-02-25T21:15:08.33+0530 [STG/0] OUT Downloading build artifacts cache...
       2019-02-25T21:15:08.40+0530 [STG/0] OUT Downloaded app package (177.4K)
       2019-02-25T21:15:14.84+0530 [STG/0] OUT Downloaded build artifacts cache (116.2M)
       2019-02-25T21:15:16.23+0530 [STG/0] OUT -----> Python Buildpack version 1.6.28
       2019-02-25T21:15:16.23+0530 [STG/0] OUT -----> Supplying Python
       2019-02-25T21:15:16.23+0530 [STG/0] OUT -----> Installing python 3.5.6
       2019-02-25T21:15:16.23+0530 [STG/0] OUT        Copy [/tmp/cache/final/dependencies/ef600f00661a7602f82a830e3ad44c62ea50a77f92c1125bd0ce5b53381ee337/python-3.5.6-linux-x64-cflinuxfs2-e0bd0cbf.tgz]
       2019-02-25T21:15:18.62+0530 [STG/0] OUT -----> Installing pip-pop 0.1.3
       2019-02-25T21:15:18.62+0530 [STG/0] OUT        Copy [/tmp/cache/final/dependencies/5b0bd37a974d85d0614bb4c03eb3f8fb800c9e6c04e0a17046c18387f04e0b89/pip-pop-0.1.3-fc106ef6.tar.gz]
       2019-02-25T21:15:22.27+0530 [STG/0] OUT -----> Running Pip Install
       2019-02-25T21:15:22.73+0530 [STG/0] OUT        Processing ./repo/mindsphere_core-0.1.0-py3-none-any.whl
       2019-02-25T21:15:22.75+0530 [STG/0] OUT        Processing ./repo/assetmanagement-3.9-py3-none-any.whl
       2019-02-25T21:15:22.79+0530 [STG/0] OUT        Collecting PyJWT==1.7.1 (from -r /tmp/app/requirements.txt (line 3))
       2019-02-25T21:15:22.86+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/87/8b/6a9f14b5f781697e51259d81657e6048fd31a113229cf346880bb7545565/PyJWT-1.7.1-py2.py3-none-any.whl
       2019-02-25T21:15:22.87+0530 [STG/0] OUT        Collecting python-dateutil==2.8.0 (from -r /tmp/app/requirements.txt (line 4))
       2019-02-25T21:15:22.90+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
       2019-02-25T21:15:22.92+0530 [STG/0] OUT        Collecting pytz==2018.9 (from -r /tmp/app/requirements.txt (line 5))
       2019-02-25T21:15:23.08+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl
       2019-02-25T21:15:23.20+0530 [STG/0] OUT        Collecting requests==2.21.0 (from -r /tmp/app/requirements.txt (line 6))
       2019-02-25T21:15:23.28+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
       2019-02-25T21:15:23.30+0530 [STG/0] OUT        Collecting six==1.12.0 (from -r /tmp/app/requirements.txt (line 7))
       2019-02-25T21:15:23.32+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
       2019-02-25T21:15:23.32+0530 [STG/0] OUT        Collecting urllib3==1.24.1 (from -r /tmp/app/requirements.txt (line 8))
       2019-02-25T21:15:23.36+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl
       2019-02-25T21:15:23.38+0530 [STG/0] OUT        Collecting certifi==2018.11.29 (from -r /tmp/app/requirements.txt (line 9))
       2019-02-25T21:15:23.41+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/9f/e0/accfc1b56b57e9750eba272e24c4dddeac86852c2bebd1236674d7887e8a/certifi-2018.11.29-py2.py3-none-any.whl
       2019-02-25T21:15:23.41+0530 [STG/0] OUT        Collecting chardet==3.0.4 (from -r /tmp/app/requirements.txt (line 10))
       2019-02-25T21:15:23.43+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
       2019-02-25T21:15:23.44+0530 [STG/0] OUT        Collecting Django==2.1.7 (from -r /tmp/app/requirements.txt (line 11))
       2019-02-25T21:15:23.67+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/c7/87/fbd666c4f87591ae25b7bb374298e8629816e87193c4099d3608ef11fab9/Django-2.1.7-py3-none-any.whl
       2019-02-25T21:15:24.52+0530 [STG/0] OUT        Collecting djangorestframework==3.9.1 (from -r /tmp/app/requirements.txt (line 12))
       2019-02-25T21:15:24.60+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/ef/13/0f394111124e0242bf3052c5578974e88e62e3715f0daf76b7c987fc6705/djangorestframework-3.9.1-py2.py3-none-any.whl
       2019-02-25T21:15:24.67+0530 [STG/0] OUT        Collecting idna==2.8 (from -r /tmp/app/requirements.txt (line 13))
       2019-02-25T21:15:24.69+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
       2019-02-25T21:15:24.70+0530 [STG/0] OUT        Collecting pip==19.0.3 (from -r /tmp/app/requirements.txt (line 14))
       2019-02-25T21:15:24.77+0530 [STG/0] OUT          Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl
       2019-02-25T21:15:24.87+0530 [STG/0] OUT        Installing collected packages: PyJWT, six, chardet, idna, urllib3, certifi, requests, mindsphere-core, python-dateutil, assetmanagement, pytz, Django, djangorestframework, pip
       2019-02-25T21:15:29.44+0530 [STG/0] OUT        Successfully installed Django-2.1.7 PyJWT-1.7.1 assetmanagement-3.9 certifi-2018.11.29 chardet-3.0.4 djangorestframework-3.9.1 idna-2.8 mindsphere-core-0.1.0 pip-19.0.3 python-dateutil-2.8.0 pytz-2018.9 requests-2.21.0 six-1.12.0 urllib3-1.24.1
       2019-02-25T21:15:30.39+0530 [STG/0] ERR Traceback (most recent call last):
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/bin/pip-grep", line 77, in <module>
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     main()
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/bin/pip-grep", line 73, in main
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     grep(**kwargs)
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/bin/pip-grep", line 50, in grep
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     r = Requirements(reqfile)
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/bin/pip-grep", line 30, in __init__
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     self.load(reqfile)
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/bin/pip-grep", line 39, in load
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     finder = PackageFinder([], [], session=requests)
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/python/lib/python3.5/site-packages/pip/_internal/index.py", line 339, in __init__
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     impl=implementation,
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/python/lib/python3.5/site-packages/pip/_internal/pep425tags.py", line 340, in get_supported
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     if is_manylinux2010_compatible():
       2019-02-25T21:15:30.39+0530 [STG/0] ERR   File "/tmp/contents555080451/deps/0/python/lib/python3.5/site-packages/pip/_internal/pep425tags.py", line 196, in is_manylinux2010_compatible
       2019-02-25T21:15:30.39+0530 [STG/0] ERR     return pip._internal.utils.glibc.have_compatible_glibc(2, 12)
       2019-02-25T21:15:30.39+0530 [STG/0] ERR AttributeError: module 'pip._internal' has no attribute 'utils'
       2019-02-25T21:15:49.36+0530 [STG/0] OUT Exit status 0
       2019-02-25T21:15:49.36+0530 [STG/0] OUT Uploading droplet, build artifacts cache...
       2019-02-25T21:15:49.36+0530 [STG/0] OUT Uploading droplet...
       2019-02-25T21:15:49.36+0530 [STG/0] OUT Uploading build artifacts cache...
       2019-02-25T21:15:50.50+0530 [API/2] OUT Creating droplet for app with guid 364c5cd1-63a3-43a2-b854-23ddd751099f
       2019-02-25T21:15:51.64+0530 [STG/0] OUT Uploaded build artifacts cache (116.2M)
       2019-02-25T21:15:57.71+0530 [STG/0] OUT Uploaded droplet (55.1M)
       2019-02-25T21:15:57.72+0530 [STG/0] OUT Uploading complete
       2019-02-25T21:15:58.10+0530 [STG/0] OUT Cell fefe8742-9a99-4e6c-b773-034414c67b95 stopping instance b1aaa9db-288e-4a97-b7ae-38b71b82f150
       2019-02-25T21:15:58.10+0530 [STG/0] OUT Cell fefe8742-9a99-4e6c-b773-034414c67b95 destroying container for instance b1aaa9db-288e-4a97-b7ae-38b71b82f150
       2019-02-25T21:15:58.42+0530 [CELL/0] OUT Cell f4a93eb5-83ac-46c9-b793-6f307874727d creating container for instance ea5664c5-6e4c-47b9-737d-35e7
       2019-02-25T21:15:59.80+0530 [CELL/0] OUT Cell f4a93eb5-83ac-46c9-b793-6f307874727d successfully created container for instance ea5664c5-6e4c-47b9-737d-35e7
       2019-02-25T21:16:00.42+0530 [STG/0] OUT Cell fefe8742-9a99-4e6c-b773-034414c67b95 successfully destroyed container for instance b1aaa9db-288e-4a97-b7ae-38b71b82f150
       2019-02-25T21:16:03.50+0530 [CELL/0] OUT Starting health monitoring of container
       2019-02-25T21:16:04.43+0530 [APP/PROC/WEB/0] OUT Operations to perform:
       2019-02-25T21:16:04.43+0530 [APP/PROC/WEB/0] OUT   Apply all migrations: admin, auth, contenttypes, sessions
       2019-02-25T21:16:04.44+0530 [APP/PROC/WEB/0] OUT Running migrations:
       2019-02-25T21:16:04.44+0530 [APP/PROC/WEB/0] OUT   No migrations to apply.
       2019-02-25T21:16:05.14+0530 [APP/PROC/WEB/0] OUT Performing system checks...
       2019-02-25T21:16:05.38+0530 [APP/PROC/WEB/0] OUT System check identified no issues (0 silenced).
       2019-02-25T21:16:05.40+0530 [APP/PROC/WEB/0] OUT February 25, 2019 - 15:46:05
       2019-02-25T21:16:05.40+0530 [APP/PROC/WEB/0] OUT Django version 2.1.7, using settings 'app.settings'
       2019-02-25T21:16:05.40+0530 [APP/PROC/WEB/0] OUT Starting development server at http://127.0.0.1:8000/
       2019-02-25T21:16:05.40+0530 [APP/PROC/WEB/0] OUT Quit the server with CONTROL-C.
       2019-02-25T21:17:03.84+0530 [CELL/0] ERR Failed to make TCP connection to port 8080: connection refused
       2019-02-25T21:17:03.84+0530 [CELL/0] ERR Timed out after 1m0s: health check never passed.
       2019-02-25T21:17:15.03+0530 [CELL/0] OUT Cell f4a93eb5-83ac-46c9-b793-6f307874727d stopping instance ea5664c5-6e4c-47b9-737d-35e7
       2019-02-25T21:17:15.03+0530 [CELL/0] OUT Cell f4a93eb5-83ac-46c9-b793-6f307874727d destroying container for instance ea5664c5-6e4c-47b9-737d-35e7

1 个答案:

答案 0 :(得分:1)

我正在为将来的访客添加解决方案。 我的应用程序使用了django随附的开发服务器(WSGI)。因此,当我的启动命令“ python manage.py runserver”正在运行时,它试图在

处启动应用程序
http://127.0.0.1:8000/

因此,我添加了生产就绪服务器“ gunicorn”,并将procfile中的启动命令更改为

web: python manage.py migrate && gunicorn app.wsgi --log-file -

此后,该应用程序成功在Cloud Foundry中启动。