简单测试CloudFoundry

本文描述一下我的CloundFoundry测试过程。我是在一台Amazon EC2服务器上操作的,那台服务器已经安装好了Rails环境。因此,本文只描述Rails环境已经安装好后使用CloudFoundry的过程。目前,使用CloundFoundry需要先到CloudFoundry.com申请注册。让我们开始吧。

1、安装命令行工具vmc

ubuntu@ip-10-128-97-185:~$ gem install vmc
Successfully installed spruz-0.2.13
Successfully installed json_pure-1.5.4
Successfully installed rubyzip2-2.0.1
Successfully installed terminal-table-1.4.4
Successfully installed interact-0.2
Successfully installed vmc-0.3.13
6 gems installed

2、使用vmc命令设置target
ubuntu@ip-10-128-97-185:~$ vmc target api.cloudfoundry.com
Succesfully targeted to [http://api.cloudfoundry.com]

3、登录,这时会用到你在cloundfoundry的账户信息

ubuntu@ip-10-128-97-185:~$ vmc login
Email: [email protected]
Password: ********
Successfully logged into [http://api.cloudfoundry.com]
4、创建测试文件

ubuntu@ip-10-128-97-185:~$ mkdir cloudfoundry
ubuntu@ip-10-128-97-185:~$ cd cloudfoundry/
ubuntu@ip-10-128-97-185:~/cloudfoundry$

ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ nano hello.rb
require 'sinatra'
get '/' do
    "Hello*from*Cloud*Foundry"
end
5、上传

ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ vmc push
Would you like to deploy from the current directory? [Yn]:
Application Name: douyw
Application Deployed URL ["douyw.cloudfoundry.com"]:
Detected a Sinatra Application, is this correct? [Yn]:
Memory Reservation ("64M", "128M", "256M", "512M", "1G", "2G") ["128M"]:
Creating Application: OK
Would you like to bind any services to 'douyw'? [yN]:
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (0K): OK
Push Status: OK
Staging Application: OK
Starting Application: OK

ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$
注意:上面的douyw为应用程序名,是自己输入的。

6、打开浏览器浏览:http://douyw.cloudfoundry.com

这时已经发布完成。下面是对上传文件修改之后的步骤。

7、重新编辑并再次上传:

ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ nano hello.rb
再次上传
ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ vmc update douyw
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (0K): OK
Push Status: OK
Stopping Application: OK
Staging Application: OK
Starting Application: OK


然后刷新浏览器,显示结果最终为:

Hello from Cloud Foundry and EC2



你可能感兴趣的:(测试,ubuntu,application,Rails,resources,Sinatra)