`
南京老油条
  • 浏览: 60643 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

为cloudfoundry添加Django支持

阅读更多

本文通过给cloudfoundry添加Django的支持,简要介绍添加Framework的方法.(如何添加Runtime请阅读 http://oldfritters.iteye.com/blog/1867876)

 

首先,向blobstore中添加Django以及相关的包,方法同前文中添加Python.

  

 

 

其次,添加package

   packaging:cf-release/packages/dea_python27/packaging

 

 

# abort script on any command that exit with a non zero value
set -e
echo "Setup python2.7.4"
tar xzvf python/python-2.7.4.tgz
(
  cd Python-2.7.4
  ./configure --prefix=${BOSH_INSTALL_TARGET} 
  make
  make install
)

echo "Setup Django"
tar xzvf python/Django-1.4.5.tar.gz
(
  cd Django-1.4.5
  echo c1oudc0w | sudo -S ${BOSH_INSTALL_TARGET}/bin/python setup.py install
)

echo "Setup Setuptools"
tar xzvf python/setuptools-0.6c11.tar.gz
(
  cd setuptools-0.6c11
  echo c1oudc0w | sudo -S ${BOSH_INSTALL_TARGET}/bin/python setup.py install
)

echo "Setup pip"
tar xzvf python/pip-1.3.1.tar.gz
(
  cd pip-1.3.1
  echo c1oudc0w | sudo -S ${BOSH_INSTALL_TARGET}/bin/python setup.py install
)

echo "Setup gunicorn"
tar xzvf python/gunicorn-0.17.4.tar.gz
(
  cd gunicorn-0.17.4
  echo c1oudc0w | sudo -S ${BOSH_INSTALL_TARGET}/bin/python setup.py install
)

echo "Setup mysql-connector-python"
tar xzvf python/mysql-connector-python-1.0.10.tar.gz
(
  cd mysql-connector-python-1.0.10
  echo c1oudc0w | sudo -S ${BOSH_INSTALL_TARGET}/bin/python setup.py install
)

echo c1oudc0w | sudo -S apt-get -y update
echo c1oudc0w | sudo -S apt-get -y --fix-missing install libmysqlclient-dev

echo "Setup MySQL-python-1.2.4b4.tar"
tar xzvf python/MySQL-python-1.2.4b4.tar.gz
(
  cd MySQL-python-1.2.4b4
  echo c1oudc0w | sudo -S ${BOSH_INSTALL_TARGET}/bin/python setup.py install
)
 

 

 

      spec:cf-release/packages/dea_python27/spec

 

---
name: dea_python27
dependencies:
files:
- python/python-2.7.4.tgz
- python/setuptools-0.6c11.tar.gz
- python/pip-1.3.1.tar.gz 
- python/MySQL-python-1.2.4b4.tar.gz
- python/mysql-connector-python-1.0.10.tar.gz
- python/gunicorn-0.17.4.tar.gz
- python/Django-1.4.5.tar.gz
 

 

 

 

blob中添加依赖包: cf-release/config/blob.yml

---
python/setuptools-0.6c11.tar.gz:
  object_id: 636b1c0e-d177-45ed-901f-b06e28485a2b
  sha: 8d1ad6384d358c547c50c60f1bfdb3362c6c4a7d
  size: 256862
python/pip-1.3.1.tar.gz:
  object_id: d86a4778-82ba-420d-9204-5923a71fe7ed
  sha: 9c70d314e5dea6f41415af814056b0f63c3ffd14
  size: 247594
python/MySQL-python-1.2.4b4.tar.gz:
  object_id: 8b5cf796-9632-4a33-aed9-4ea64845a4fe
  sha: 1801dba46f45a8596d17424bf07a747c7bac841f
  size: 79704
python/mysql-connector-python-1.0.10.tar.gz:
  object_id: ba10a05a-ca71-41cf-bf5a-3bc0558bd984
  sha: 31d26132f8089b25aed6255b835c8df60fe61c9a
  size: 234122
python/gunicorn-0.17.4.tar.gz:
  object_id: ff817558-6c7a-426f-861b-492ef38ea2e2
  sha: ca4c95a236fd90dcf46ffa35c150d9564336e150
  size: 372737
python/python-2.7.4.tgz:
  object_id: 94ec890f-ae43-455c-932d-49aa9d34e462
  sha: 2283858b832fc391b8e96bb600e0b39e52ae97bd
  size: 14489063
python/Django-1.4.5.tar.gz:
  object_id: 354c918e-fb75-431b-81e4-dacd1b7cbdf6
  sha: 1bfaa4643c6775fbf394137f1533659be45441e7
  size: 7735582

 

添加runtime支持: cf-release/jobs/cloud_controller/templates/runtimes.yml

 

---
python27:
  description: Python
  version: "2.7.4"
  executable: /var/vcap/packages/dea_python27/bin/python
  soft_link_folder: python/bin
  soft_link_targets:
    executable: /var/vcap/packages/dea_python27/bin/python
    gunicorn_django: /var/vcap/packages/dea_python27/bin/gunicorn_django
    django: /var/vcap/packages/dea_python27/bin/django-admin.py
    gunicorn: /var/vcap/packages/dea_python27/bin/gunicorn
    gunicorn_paster: /var/vcap/packages/dea_python27/bin/gunicorn_paster
  soft_links:
    executable: python/bin/python
    gunicorn_django: python/bin/gunicorn_django
    django: python/bin/django
    gunicorn: python/bin/gunicorn
    gunicorn_paster: python/bin/gunicorn_paster
  staging: /var/vcap/packages/ruby/bin/ruby stage
  version_output: 2.7.4
  version_flag: "-c 'import platform; print platform.python_version()'"
  environment:
    PATH: /var/vcap/packages/ruby/bin:/var/vcap/packages/dea_python27/bin:/var/vcap/packages/imagemagick/bin:$PATH
    LD_LIBRARY_PATH: '/var/vcap/packages/mysqlclient/lib/mysql:/var/vcap/packages/sqlite/lib:/var/vcap/packages/libpq/lib:/var/vcap/packages/imagemagick/lib:$LD_LIBRARY_PATH'
  debug_modes:
    - run
    - suspend
  status:
    name: current
  series: python27
  category: python

 

添加Django支持: cf-release/jobs/cloud_controller/templates/django.yml

---
name: django

runtimes:
  - python27:
      default: true
detection:
  - manage.py: true

 

 

 修改代码:cf-release/src/dea/lib/dea/agent.rb

   def stage_app_dir(bits_file, bits_uri, sha1, tgz_file, instance_dir, runtime)
      ......
      FileUtils.rm_f(tgz_file) unless @disable_dir_cleanup
      add_runtime_soft_links instance_dir,runtime if runtime['soft_link_tagets'] && runtime['soft_links'] && runtime['soft_link_folder']
      bind_local_runtime(instance_dir, runtime)
      @logger.debug("Took #{Time.now - start} to stage the app directory")
      true
    end
    
  #此方法是额外添加的
     def add_runtime_soft_links instance_dir, runtime
      FileUtils.mkdir_p [instance_dir, runtime['soft_link_folder']].join('/')
      runtime['soft_link_targets'].each{|key| FileUtils.ln_s runtime['soft_link_targets'][key], [instance_dir, runtime['soft_links'][key]].join('/') }
    end

 

 

分享到:
评论

相关推荐

    Spring 与 Cloud Foundry:在云中珠联璧合

    Spring Cloud为Cloud Foundry中的服务提供了注册与发现机制,通过Spring Cloud Config Server,应用程序可以在运行时动态获取或更新配置信息,使得环境适应性和灵活性大大提升。 Cloud Foundry的健康检查机制与...

    Cloud Foundry:云时代的Linux/LAMP.pdf

    例如,AppFog基于Cloud Foundry并增加了PHP支持,AppState建立了支持Perl和Python的私有云,而Tier 3则为Cloud Foundry添加了.NET支持。 在中国,新浪SAE宣布基于Cloud Foundry增加对Ruby的支持,盛大云的OC Luong...

    Cloud Foundry: The Definitive Guide

    Cloud Foundry是一个开源的PaaS(平台即服务)平台,旨在为开发者提供一个快速开发、部署和运行应用程序的环境。它最初由VMware发起,并于2011年公开发布,随后在Pivotal公司得到了进一步的发展。Cloud Foundry支持...

    CloudFoundry服务网关的架构

    CloudFoundry作为一个开源的PaaS(Platform as a Service)平台,为开发者提供了极大的灵活性,让他们能够在不同的云平台上选择开发框架与应用服务。该平台最初由VMware创建,并迅速获得了业界广泛支持。 - **Cloud...

    Cloud Foundry合作伙伴战略和案例分享

    最后,"刘海峰_盛大云PaaS平台.ppt"可能涉及的是盛大云(现为青云QingCloud)如何利用Cloud Foundry构建自己的PaaS平台。刘海峰可能会介绍盛大云如何将Cloud Foundry作为核心技术,打造适合中国市场的云服务,以及在...

    CloudFoundry中MongoDB的应用

    自发布以来,CloudFoundry获得了行业的广泛支持,并逐渐成为许多企业和开发者首选的PaaS解决方案之一。 **如何使用CloudFoundry:** - 访问官方网址注册账户:开发者可以通过访问<https://my.cloudfoundry....

    Cloud Foundry平台概述

    Cloud Foundry是一种领先的开源平台即服务(PaaS)解决方案,旨在为开发者提供一种简便的方式来构建、测试和部署应用程序,同时为运维团队提供了强大的自动化管理和资源调度能力。它由VMware公司发起,现已发展成为...

    cloudfoundry-runtime-0.8.4_Java8_cloud_

    【标题】"cloudfoundry-runtime-0.8.4_Java8_cloud_" 指的是一个针对 Cloud Foundry 运行时环境的特定版本,这个版本是为 Java 8 语言定制的。Cloud Foundry 是一个开源的平台即服务(PaaS)系统,允许开发者构建、...

    Cloud Foundry 中的新增功能-中英文

    作为多语言平台,Cloud Foundry已经支持Java、Ruby、Node.js、Python等,但随着技术的发展,它可能会增加对Kotlin、Go或其他新兴语言的支持,以满足不同开发团队的需求。 在安全性方面,Cloud Foundry的新功能可能...

    Cloudfoundry

    Cloudfoundry

    Cloud Foundry - The Definitive Guide

    Get started with Cloud Foundry, the leading Platform as a Service (PaaS) that’s dramatically changing how developers, operations practitioners, and especially DevOps teams deploy applications and ...

    基于CloudFoundry的PaaS云平台的设计与实现

    CloudFoundry支持多种编程语言和框架,如Java、.NET、Ruby on Rails、Node.js、Grails、Scala on Lift、Python和PHP等,因此它为不同背景的开发者提供了极大的便利。 在探讨CloudFoundry的架构组件之前,需要了解...

    CloudFoundry开源云计算平台简介.rar

    CloudFoundry开源云计算平台简介rar,提供“CloudFoundry开源云计算平台简介”免费资料下载,主要包括Cloud Foundry的概述、Cloud Foundry的架构、使用Cloud Foundry部署应用等内容,可供学习使用。

    CF-Help.rar_Help!_cloudfoundry_cloudfoundry Help

    这个“CF-Help.rar”压缩包显然包含了与CloudFoundry相关的帮助文档,旨在为用户提供简洁而实用的搜索功能。 CloudFoundry的核心功能包括: 1. **应用生命周期管理**:它支持多种编程语言,如Java, .NET, Ruby, ...

    喻勇 2012-08-12 Cloud Foundry的弹性设计

    Cloud Foundry 被定位为 PaaS (Platform as a Service) 层次上的解决方案,介于 IaaS (Infrastructure as a Service) 和 SaaS (Software as a Service) 之间。具体来说: - **IaaS**:关注于硬件级别的自动化管理和...

    Cloudfoundry介绍文档

    CloudFoundry的介绍文档,入门必备

    从开发者的角度看CloudFoundry

    CloudFoundry支持多种语言和框架,例如Node.js、Ruby、Java等,并且支持多种数据库服务如PostgreSQL、MongoDB等。这种开放性和灵活性使得CloudFoundry成为了一个非常受欢迎的PaaS解决方案。 #### 二、CloudFoundry...

    CloudFoundry云平台部署手册.pdf

    CloudFoundry云平台部署手册.pdf

    Cloud Foundry 体系结构

    Cloud Foundry 是一个开源的平台即服务(PaaS)系统,专为构建、部署和管理应用程序而设计。它提供了一种高效、灵活的云环境,让开发者能够专注于编写代码,而不必关心底层基础设施的运维。Cloud Foundry 的体系结构...

Global site tag (gtag.js) - Google Analytics