# install ruby, below is the ubuntu distro way, use pkg installer accordingly
sudo apt‐get install ruby‐full
sudo apt‐get install rubygems
sudo install gem vmc
# either add to $PATH on .bashrc or just create quickly an alias as below
alias vmc='/var/lib/gems/1.8/bin/vmc'
# once installed then launch vmc then with a target cloud + login
vmc target api.cloudfoundry.com
vmc login
> enter email and password, you can use 'vmc passwd' to reset given temp password
> roo
script /samples/clinic.roo
perform package
exit
cd yourRooProjRoot/target/petclinic-0.1.0.BUILD-SNAPSHOT
vmc push
# accept all defaults and give a unique name
https://petclinicroo.cloudfoundry.com
And below are some useful vmc app commands you can run afterwards:
- vmc -h
- vmc apps
- vmc stats petclinicroo
- vmc logs petclinicroo
- vmc instances petclinicroo
- vmc logout
https://restgrid.cloudfoundry.com (System.getenv("VCAP_APPLICATION") != null) ? "Cloud" : "Local" )
public class CloudApplicationContextInitializer implements
ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
CloudEnvironment env = new CloudEnvironment();
if (env.getInstanceInfo() != null) {
applicationContext.getEnvironment().setActiveProfiles("cloud");
} else {
applicationContext.getEnvironment().setActiveProfiles("dev");
}
}
}
<mongo:db-factory id="mongoDbFactory"
dbname="#{serviceProperties['mongodb-db.db']}"
host="#{serviceProperties['mongodb-db.hostname']}"
port="#{serviceProperties['mongodb-db.port']}"
username="#{serviceProperties['mongodb-db.username']}"
password="#{serviceProperties['mongodb-db.password']}"
/>
<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>
<beans profile="dev">
<util:properties id="serviceProperties">
<prop key="mongodb-db.db">db</prop>
<prop key="mongodb-db.hostname">127.0.0.1</prop>
<prop key="mongodb-db.port">27017</prop>
<prop key="mongodb-db.username">xxx</prop>
<prop key="mongodb-db.password">xxx</prop>
</util:properties>
</beans>
<beans profile="cloud">
<cloud:service-properties id="serviceProperties"/>
</beans>
$ vmc apps +--------------+----+---------+-------------------------------+------------+ | Application | # | Health | URLS | Services | +--------------+----+---------+-------------------------------+------------+ | petclinicroo | 1 | RUNNING | petclinicroo.cloudfoundry.com | | | restgrid | 1 | RUNNING | restgrid.cloudfoundry.com | mongodb-db | +--------------+----+---------+-------------------------------+------------+ $ vmc services ============== System Services ============== +----------+---------+-------------------------------+ | Service | Version | Description | +----------+---------+-------------------------------+ | mongodb | 1.8 | MongoDB NoSQL store | | mysql | 5.1 | MySQL database service | | rabbitmq | 2.4 | RabbitMQ messaging service | | redis | 2.2 | Redis key-value store service | +----------+---------+-------------------------------+ =========== Provisioned Services ============ +------------+---------+ | Name | Service | +------------+---------+ | mongodb-db | mongodb | +------------+---------+
Update 09/2011 I'd like to share a project (that recently deployed to the cloud) from post which plots in a graph histogram for given datasets (you can select multiple rows to view combined results)
https://rest-stats.cloudfoundry.com
And the respective System.getProperties() + System.getenv() could be seen here Cheers

0 comments:
Post a Comment