22
GE Predix .. By Kai Zhao [email protected] https://cn.linkedin.com/in/kai-zhao-63403212 & Zheming Zhang https://cn.linkedin.com/in/sonny-zhang-184a4761 Code Repository https://github.com/cloudfoundry-samples https://github.com/PredixDev VCAP- SERVICES http://docs.run.pivotal.io/devguide/deploy-apps/environment- variable.html#VCAP-SERVICES Environment Variable http://docs.run.pivotal.io/devguide/deploy-apps/environment- variable.html CF all cmds http://cli.cloudfoundry.org/en-US/cf/ Service Broker http://blog.csdn.net/zhaozhenyang_go/article/details/32078665 Overview of CF https://docs.cloudfoundry.org/concepts/overview.html Predix Entry https://predix-io.run.xxxx.predix.io

GE Predix 新手入门 赵锴 物联网_IoT

Embed Size (px)

Citation preview

Page 1: GE Predix 新手入门 赵锴 物联网_IoT

GEPredix���

����.�� .���

By �� Kai Zhao [email protected] https://cn.linkedin.com/in/kai-zhao-63403212 & ���� Zheming Zhang

https://cn.linkedin.com/in/sonny-zhang-184a4761

Code Repository

https://github.com/cloudfoundry-samples https://github.com/PredixDev

VCAP-SERVICES

http://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES

Environment Variable

http://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html

CF all cmds http://cli.cloudfoundry.org/en-US/cf/ Service Broker http://blog.csdn.net/zhaozhenyang_go/article/details/32078665 Overview of CF

https://docs.cloudfoundry.org/concepts/overview.html

Predix Entry https://predix-io.run.xxxx.predix.io

Page 2: GE Predix 新手入门 赵锴 物联网_IoT

Step 1: Install the cf-clli

References https://github.com/cloudfoundry/cli#downloads Actions Mac OS X (using Homebrew via the cloudfoundry tap):

$ brew tap cloudfoundry/tap $ brew install cf-cli

KaiZhaos-MacBook-Pro:~ kaizhao$ brew tap cloudfoundry/tap ==> Tapping cloudfoundry/tap Cloning into '/usr/local/Library/Taps/cloudfoundry/homebrew-tap'... remote: Counting objects: 10, done. remote: Compressing objects: 100% (9/9), done. remote: Total 10 (delta 0), reused 5 (delta 0), pack-reused 0 Unpacking objects: 100% (10/10), done. Checking connectivity... done. Tapped 3 formulae (39 files, 43.2K) KaiZhaos-MacBook-Pro:~ kaizhao$ brew install cf-cli ==> Installing cf-cli from cloudfoundry/tap ==> Downloading https://cli.run.pivotal.io/stable?release=macosx64-binary&versio ==> Downloading from https://s3-us-west-1.amazonaws.com/cf-cli-releases/releases ######################################################################## 100.0% ! /usr/local/Cellar/cf-cli/6.22.2: 2 files, 20.5M, built in 6 minutes 37 seconds KaiZhaos-MacBook-Pro:~ kaizhao$ cf cf version 6.22.2+a95e24c-2016-10-27, Cloud Foundry command line tool Usage: cf [global options] command [arguments...] [command options] Before getting started: config login,l target,t help,h logout,lo Application lifecycle: apps,a logs set-env,se push,p ssh create-app-manifest start,st app stop,sp env,e restart,rs scale restage,rg events

Page 3: GE Predix 新手入门 赵锴 物联网_IoT

Services integration: marketplace,m create-user-provided-service,cups services,s update-user-provided-service,uups create-service,cs create-service-key,csk update-service delete-service-key,dsk delete-service,ds service-keys,sk service service-key bind-service,bs bind-route-service,brs unbind-service,us unbind-route-service,urs Route and domain management: routes,r delete-route create-domain domains map-route create-route unmap-route Space management: spaces create-space set-space-role space-users delete-space unset-space-role Org management: orgs,o set-org-role org-users unset-org-role CLI plugin management: plugins add-plugin-repo repo-plugins install-plugin list-plugin-repos Commands offered by installed plugins: Global options: --help, -h Show help -v Print API request diagnostics to stdout 'cf help -a' lists all commands with short descriptions. See 'cf help <command>' to read about a specific command.

Step 2: Connect to the CloudFoundry with cf login

References http://docs.cloudfoundry.org/cf-cli/getting-started.html KaiZhaos-MacBook-Pro:~ kaizhao$ cf login -a https://api.system.xxxx.predix.io -u [email protected] API endpoint: https://api.system.xxxx.predix.io Password> Authenticating...

Page 4: GE Predix 新手入门 赵锴 物联网_IoT

OK Targeted org Shanghai_Foundry Targeted space [email protected] API endpoint: https://api.system.xxxx.predix.io (API version: 2.62.0) User: [email protected] Org: Shanghai_Foundry Space: [email protected] KaiZhaos-MacBook-Pro:~ kaizhao$ Step 3:List all marketplace offering References

http://cli.cloudfoundry.org/en-US/cf/marketplace.html

NAME marketplace - List available offerings in the marketplace

USAGE cf marketplace [-s SERVICE]

ALIAS m

OPTIONS -s

Show plan details for a particular service offering

SEE ALSO create-service, services

KaiZhaos-MacBook-Pro:~ kaizhao$ cf marketplace Getting services from marketplace in org Shanghai_Foundry / space [email protected] as [email protected]... OK service plans description event-audit-trail Beta A service to create and maintain an event audit trail

Page 5: GE Predix 新手入门 赵锴 物联网_IoT

logstash free Logstash 1.4 service for application development and testing p-rabbitmq-35 standard RabbitMQ is a robust and scalable high-performance multi-protocol messaging broker. postgres shared-nr, shared, Dedicated-R-Bronze Reliable PostgrSQL Service predix-acs Tiered*, Free Use this service to provide a more powerful framework than basic User Account and Authentication. predix-analytics-catalog Bronze*, Silver*, Gold*, Free Add analytics to the Predix cloud for use with the Analytics Runtime Service. predix-analytics-runtime Bronze*, Silver*, Gold*, Free Use this service to support elastic execution of the analytic orchestration. predix-analytics-ui Free Use this browser-based user interface to upload, validate, and run analytics. predix-asset Free, Tiered* Create and store machine asset models and instances. predix-blobstore Tiered* Use this binary large object storage (BLOB) to securely store large byte arrays and retrieve data using any file type. predix-tms Tiered* Use this service to provision service instances for a tenant and provide runtime access. predix-uaa Tiered*, Free Use this service for a full-featured OAuth 2.0 server. predix-views Standard*, Free Control layout and components within your client-side web or mobile app. rabbitmq-36 standard RabbitMQ is a robust and scalable high-performance multi-protocol messaging broker. redis shared-vm Redis service to provide a key-value store * These service plans have an associated cost. Creating a service instance will incur this cost. TIP: Use 'cf marketplace -s SERVICE' to view descriptions of individual plans of a given service. KaiZhaos-MacBook-Pro:~ kaizhao$ cf marketplace -s postgres Getting service plan information for service postgres as [email protected]... OK service plan description free or paid shared-nr A PostgreSQL database with no replication on a shared server. free

Page 6: GE Predix 新手入门 赵锴 物联网_IoT

shared A Reliable PostgreSQL database on a shared server. free Dedicated-R-Bronze Replicated database in a dedicated environment (Beta) free KaiZhaos-MacBook-Pro:~ kaizhao$ Step 4: List all services References http://cli.cloudfoundry.org/en-US/cf/services.html

cf services KaiZhaos-MacBook-Pro:~ kaizhao$ cf services Getting services in org Shanghai_Foundry / space [email protected] as [email protected]... OK name service plan bound apps last operation kzpgsql postgres shared-nr create succeeded KaiZhaos-MacBook-Pro:~ kaizhao$ Step 5: Show service instance info References https://docs.cloudfoundry.org/cf-cli/cf-

help.html#services cf service service_instance use –guid to retrieve and display the guid of the service instance

KaiZhaos-MacBook-Pro:~ kaizhao$ cf services Getting services in org Shanghai_Foundry / space [email protected] as [email protected]... OK name service plan bound apps last operation kzpgsql postgres shared-nr create succeeded KaiZhaos-MacBook-Pro:~ kaizhao$ cf service kzpgsql Service instance: kzpgsql Service: postgres Bound apps: Tags: Plan: shared-nr Description: Reliable PostgrSQL Service Documentation url: Dashboard: Last Operation Status: create succeeded Message: Started: 2016-11-23T14:08:25Z Updated:

Page 7: GE Predix 新手入门 赵锴 物联网_IoT

KaiZhaos-MacBook-Pro:~ kaizhao$ cf service kzpgsql --guid 72a9143d-98f6-4b21-a9e0-a6cc11acb1cf Step 5: Create a service instance KaiZhaos-MacBook-Pro:~ kaizhao$ cf create-service postgres shared-nr kzpgsql2 Creating service instance kzpgsql2 in org Shanghai_Foundry / space [email protected] as [email protected]... OK KaiZhaos-MacBook-Pro:~ kaizhao$ cf services Getting services in org Shanghai_Foundry / space [email protected] as [email protected]... OK name service plan bound apps last operation kzpgsql postgres shared-nr create succeeded kzpgsql2 postgres shared-nr create succeeded KaiZhaos-MacBook-Pro:~ kaizhao$ cf service kzpgsql2 Service instance: kzpgsql2 Service: postgres Bound apps: Tags: Plan: shared-nr Description: Reliable PostgrSQL Service Documentation url: Dashboard: Last Operation Status: create succeeded Message: Started: 2016-11-23T15:23:11Z Updated: Step 6: Create a user provided service and add to cf KaiZhaos-MacBook-Pro:~ kaizhao$ cf create-user-provided-service viz -r https://www.connectf.com/fe Creating user provided service viz in org Shanghai_Foundry / space [email protected] as [email protected]... OK KaiZhaos-MacBook-Pro:~ kaizhao$ cf services Getting services in org Shanghai_Foundry / space [email protected] as [email protected]... OK name service plan bound apps last operation kzpgsql postgres shared-nr create succeeded

Page 8: GE Predix 新手入门 赵锴 物联网_IoT

kzpgsql2 postgres shared-nr create succeeded viz user-provided

Step 7: Push application Reference https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html

KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ ls README.md Staticfile hello-world.py index.html manifest.yml KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ cf push Using manifest file /Users/kaizhao/Desktop/Predix/cf/predixdev/Predix-HelloWorld-WebApp/manifest.yml Using stack cflinuxfs2... OK Creating app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK Creating route predix-helloworld-webapp-kz.run.xxxx.predix.io... OK Binding predix-helloworld-webapp-kz.run.xxxx.predix.io to Predix-HelloWorld-WebApp-KZ... OK

Page 9: GE Predix 新手入门 赵锴 物联网_IoT

Uploading Predix-HelloWorld-WebApp-KZ... Uploading app files from: /Users/kaizhao/Desktop/Predix/cf/predixdev/Predix-HelloWorld-WebApp Uploading 3.1K, 4 files Done uploading OK Starting app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... -----> Downloaded app package (4.0K) -------> Buildpack version 1.3.10 Downloaded [file:///var/vcap/data/dea_next/admin_buildpacks/51ffcab3-8408-4bef-8a59-5180999db286_b476477d537f3b4e29b121b7cd4fde0f57bd730f/dependencies/https___buildpacks.cloudfoundry.org_concourse-binaries_nginx_nginx-1.11.3-linux-x64.tgz] -----> Using root folder -----> Copying project files into public/ -----> Setting up nginx -----> Uploading droplet (2.6M) 1 of 1 instances running App started OK App Predix-HelloWorld-WebApp-KZ was started using this command `sh boot.sh` Showing health and status for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK requested state: started instances: 1/1 usage: 256M x 1 instances urls: predix-helloworld-webapp-kz.run.xxxx.predix.io last uploaded: Wed Nov 23 18:03:12 UTC 2016 stack: cflinuxfs2 buildpack: staticfile_buildpack state since cpu memory disk details #0 running 2016-11-24 02:03:25 AM 0.0% 3.7M of 256M 5.6M of 1G

Page 10: GE Predix 新手入门 赵锴 物联网_IoT

Step 8: Show all environment variables for an application instance Reference http://cli.cloudfoundry.org/en-US/cf/env.html

KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ cf env Predix-HelloWorld-WebApp-KZ Getting env variables for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK System-Provided: { "VCAP_APPLICATION": { "application_id": "95d878d5-600b-4672-b9ca-5b3a69c615d5", "application_name": "Predix-HelloWorld-WebApp-KZ", "application_uris": [ "predix-helloworld-webapp-kz.run.xxxx.predix.io" ], "application_version": "3487cb8c-3260-485a-a915-c845fb2aef8d", "limits": { "disk": 1024, "fds": 16384, "mem": 256 }, "name": "Predix-HelloWorld-WebApp-KZ", "space_id": "46d6aa19-f64e-46be-84d6-f888701a68d0", "space_name": "[email protected]", "uris": [ "predix-helloworld-webapp-kz.run.xxxx.predix.io" ], "users": null, "version": "3487cb8c-3260-485a-a915-c845fb2aef8d"

Page 11: GE Predix 新手入门 赵锴 物联网_IoT

} } No user-defined env variables have been set No running env variables have been set No staging env variables have been set Step 9: Bind application with service References http://cli.cloudfoundry.org/en-US/cf/bind-

service.html KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ cf env Predix-HelloWorld-WebApp-KZ Getting env variables for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK System-Provided: { "VCAP_APPLICATION": { "application_id": "95d878d5-600b-4672-b9ca-5b3a69c615d5", "application_name": "Predix-HelloWorld-WebApp-KZ", "application_uris": [ "predix-helloworld-webapp-kz.run.xxxx.predix.io" ], "application_version": "3487cb8c-3260-485a-a915-c845fb2aef8d", "limits": { "disk": 1024, "fds": 16384, "mem": 256 }, "name": "Predix-HelloWorld-WebApp-KZ", "space_id": "46d6aa19-f64e-46be-84d6-f888701a68d0", "space_name": "[email protected]", "uris": [ "predix-helloworld-webapp-kz.run.xxxx.predix.io" ], "users": null, "version": "3487cb8c-3260-485a-a915-c845fb2aef8d" } } No user-defined env variables have been set No running env variables have been set

Page 12: GE Predix 新手入门 赵锴 物联网_IoT

No staging env variables have been set KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ cf bind-service predix-helloworld-webapp-kz kzpgsql Binding service kzpgsql to app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK TIP: Use 'cf restage Predix-HelloWorld-WebApp-KZ' to ensure your env variable changes take effect KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ cf restage Predix-HelloWorld-WebApp-KZ Restaging app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... -----> Downloaded app package (4.0K) -----> Downloaded app buildpack cache (4.0K) -------> Buildpack version 1.3.10 Downloaded [file:///var/vcap/data/dea_next/admin_buildpacks/51ffcab3-8408-4bef-8a59-5180999db286_b476477d537f3b4e29b121b7cd4fde0f57bd730f/dependencies/https___buildpacks.cloudfoundry.org_concourse-binaries_nginx_nginx-1.11.3-linux-x64.tgz] -----> Using root folder -----> Copying project files into public/ -----> Setting up nginx -----> Uploading droplet (2.6M) 1 of 1 instances running App started OK App Predix-HelloWorld-WebApp-KZ was started using this command `sh boot.sh` Showing health and status for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK requested state: started instances: 1/1 usage: 256M x 1 instances urls: predix-helloworld-webapp-kz.run.xxxx.predix.io last uploaded: Wed Nov 23 18:03:12 UTC 2016 stack: cflinuxfs2 buildpack: staticfile_buildpack state since cpu memory disk details

Page 13: GE Predix 新手入门 赵锴 物联网_IoT

#0 running 2016-11-24 02:17:37 AM 0.0% 3.8M of 256M 5.6M of 1G KaiZhaos-MacBook-Pro:Predix-HelloWorld-WebApp kaizhao$ cf env Predix-HelloWorld-WebApp-KZ Getting env variables for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK System-Provided: { "VCAP_SERVICES": { "postgres": [ { "credentials": { "ID": 0, "binding_id": "3ce9dfeb-d0f4-4a00-899b-46eff5da03d8", "database": "db128956807f549728dad6a7e2300d9b4", "dsn": "host=10.120.8.137 port=5432 user=ub128956807f549728dad6a7e2300d9b4 password=e2432869763245c684e855e7a393b463 dbname=db128956807f549728dad6a7e2300d9b4 connect_timeout=5 sslmode=disable", "host": "10.120.8.137", "instance_id": "72a9143d-98f6-4b21-a9e0-a6cc11acb1cf", "jdbc_uri": "jdbc:postgresql://10.120.8.137:5432/db128956807f549728dad6a7e2300d9b4?user=ub128956807f549728dad6a7e2300d9b4\u0026password=e2432869763245c684e855e7a393b463\u0026ssl=false", "password": "e2432869763245c684e855e7a393b463", "port": "5432", "uri": "postgres://ub128956807f549728dad6a7e2300d9b4:[email protected]:5432/db128956807f549728dad6a7e2300d9b4?sslmode=disable", "username": "ub128956807f549728dad6a7e2300d9b4" }, "label": "postgres", "name": "kzpgsql", "plan": "shared-nr", "provider": null, "syslog_drain_url": null, "tags": [ "rdpg", "postgresql" ], "volume_mounts": [] } ] } } { "VCAP_APPLICATION": {

Page 14: GE Predix 新手入门 赵锴 物联网_IoT

"application_id": "95d878d5-600b-4672-b9ca-5b3a69c615d5", "application_name": "Predix-HelloWorld-WebApp-KZ", "application_uris": [ "predix-helloworld-webapp-kz.run.xxxx.predix.io" ], "application_version": "b9ba301c-ff4d-4ec9-bc9d-d4034a0dcf84", "limits": { "disk": 1024, "fds": 16384, "mem": 256 }, "name": "Predix-HelloWorld-WebApp-KZ", "space_id": "46d6aa19-f64e-46be-84d6-f888701a68d0", "space_name": "[email protected]", "uris": [ "predix-helloworld-webapp-kz.run.xxxx.predix.io" ], "users": null, "version": "b9ba301c-ff4d-4ec9-bc9d-d4034a0dcf84" } } No user-defined env variables have been set No running env variables have been set No staging env variables have been set

Page 15: GE Predix 新手入门 赵锴 物联网_IoT

Step 10: Create service key for service instance References http://cli.cloudfoundry.org/en-US/cf/bind-

service.html KaiZhaos-MacBook-Pro:~ kaizhao$ cf create-service-key kzpgsql2 kzpgsqlkey2 Creating service key kzpgsqlkey2 for service instance kzpgsql2 as [email protected]... OK KaiZhaos-MacBook-Pro:~ kaizhao$ cf service-key kzpgsql2 kzpgsqlkey2 Getting key kzpgsqlkey2 for service instance kzpgsql2 as [email protected]... { "ID": 0, "binding_id": "d7342d96-7680-4e61-94fd-35419d6ecab0", "database": "d8c27e972779844d0b31ad0b2e4d7b821", "dsn": "host=10.120.8.137 port=5432 user=u8c27e972779844d0b31ad0b2e4d7b821 password=68eddfeec36940489ee42e07d2ba1271 dbname=d8c27e972779844d0b31ad0b2e4d7b821 connect_timeout=5 sslmode=disable", "host": "10.120.8.137", "instance_id": "15e876dd-e3a3-4ded-842a-fa27f1703221", "jdbc_uri": "jdbc:postgresql://10.120.8.137:5432/d8c27e972779844d0b31ad0b2e4d7b821?user=u8c27e972779844d0b31ad0b2e4d7b821\u0026password=68eddfeec36940489ee42e07d2ba1271\u0026ssl=false", "password": "68eddfeec36940489ee42e07d2ba1271",

Page 16: GE Predix 新手入门 赵锴 物联网_IoT

"port": "5432", "uri": "postgres://u8c27e972779844d0b31ad0b2e4d7b821:[email protected]:5432/d8c27e972779844d0b31ad0b2e4d7b821?sslmode=disable", "username": "u8c27e972779844d0b31ad0b2e4d7b821" } KaiZhaos-MacBook-Pro:~ kaizhao$ Step 11: Print the version Reference http://cli.cloudfoundry.org/en-US/cf/version.html

KaiZhaos-MacBook-Pro:~ kaizhao$ cf version cf version 6.22.2+a95e24c-2016-10-27 Step 12: Set or view target api url Reference http://cli.cloudfoundry.org/en-US/cf/api.html

cf api KaiZhaos-MacBook-Pro:~ kaizhao$ cf api API endpoint: https://api.system.xxxx.predix.io (API version: 2.62.0) KaiZhaos-MacBook-Pro:~ kaizhao$ Step 13: Application Scalable Reference http://cli.cloudfoundry.org/en-US/cf/scale.html

USAGE

cf scale APP_NAME [-i INSTANCES] [-k DISK] [-m MEMORY] [-f]

OPTIONS

-f

Force restart of app without prompt

-i

Page 17: GE Predix 新手入门 赵锴 物联网_IoT

Number of instances

-k

Disk limit (e.g. 256M, 1024M, 1G)

-m

Memory limit (e.g. 256M, 1024M, 1G)

scale - Change or view the instance count, disk space limit, and memory limit for an app KaiZhaos-MacBook-Pro:~ kaizhao$ cf scale Predix-HelloWorld-WebApp-KZ Showing current scale of app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK memory: 256M disk: 1G instances: 1 KaiZhaos-MacBook-Pro:~ kaizhao$ cf scale Predix-HelloWorld-WebApp-KZ Showing current scale of app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK memory: 256M disk: 1G instances: 1 KaiZhaos-MacBook-Pro:~ kaizhao$ cf scale Predix-HelloWorld-WebApp-KZ -m 512M This will cause the app to restart. Are you sure you want to scale Predix-HelloWorld-WebApp-KZ?> y Scaling app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK Stopping app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK Starting app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... 0 of 1 instances running, 1 starting 1 of 1 instances running App started

Page 18: GE Predix 新手入门 赵锴 物联网_IoT

OK App Predix-HelloWorld-WebApp-KZ was started using this command `sh boot.sh` Showing health and status for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK requested state: started instances: 1/1 usage: 512M x 1 instances urls: predix-helloworld-webapp-kz.run.xxxx.predix.io last uploaded: Wed Nov 23 18:03:12 UTC 2016 stack: cflinuxfs2 buildpack: staticfile_buildpack state since cpu memory disk details #0 running 2016-11-24 09:39:09 PM 0.0% 3.8M of 512M 5.6M of 1G KaiZhaos-MacBook-Pro:~ kaizhao$ cf scale Predix-HelloWorld-WebApp-KZ Showing current scale of app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK memory: 512M disk: 1G instances: 1 KaiZhaos-MacBook-Pro:~ kaizhao$ Step 14: Stop all instances of the app, then start them again. This may cause downtime. Reference http://cli.cloudfoundry.org/en-US/cf/restart.html

cf restart APP_NAME KaiZhaos-MacBook-Pro:~ kaizhao$ cf restart Predix-HelloWorld-WebApp-KZ Stopping app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK Starting app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... 1 of 1 instances running

Page 19: GE Predix 新手入门 赵锴 物联网_IoT

App started OK App Predix-HelloWorld-WebApp-KZ was started using this command `sh boot.sh` Showing health and status for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK requested state: started instances: 1/1 usage: 512M x 1 instances urls: predix-helloworld-webapp-kz.run.xxxx.predix.io last uploaded: Wed Nov 23 18:03:12 UTC 2016 stack: cflinuxfs2 buildpack: staticfile_buildpack state since cpu memory disk details #0 running 2016-11-24 10:24:58 PM 0.0% 3.7M of 512M 5.6M KaiZhaos-MacBook-Pro:~ kaizhao$ cf app Predix-HelloWorld-WebApp-KZ Showing health and status for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK requested state: started instances: 1/1 usage: 512M x 1 instances urls: predix-helloworld-webapp-kz.run.xxxx.predix.io last uploaded: Wed Nov 23 18:03:12 UTC 2016 stack: cflinuxfs2 buildpack: staticfile_buildpack state since cpu memory disk details #0 running 2016-11-24 10:24:58 PM 0.0% 3.7M of 512M 5.6M of 1G Step 15: Show recent application events Reference http://cli.cloudfoundry.org/en-US/cf/events.html

cf events APP_NAME KaiZhaos-MacBook-Pro:~ kaizhao$ cf events Predix-HelloWorld-WebApp-KZ Getting events for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]...

Page 20: GE Predix 新手入门 赵锴 物联网_IoT

time event actor description 2016-11-24T22:24:56.00+0800 audit.app.update [email protected] state: STARTED 2016-11-24T22:24:40.00+0800 audit.app.update [email protected] state: STOPPED 2016-11-24T21:39:08.00+0800 audit.app.update [email protected] state: STARTED 2016-11-24T21:39:03.00+0800 audit.app.update [email protected] state: STOPPED 2016-11-24T21:39:01.00+0800 audit.app.update [email protected] memory: 512 2016-11-24T03:05:44.00+0800 audit.app.restage [email protected] 2016-11-24T02:17:31.00+0800 audit.app.restage [email protected] 2016-11-24T02:03:18.00+0800 audit.app.update [email protected] state: STARTED 2016-11-24T02:03:06.00+0800 audit.app.update [email protected] 2016-11-24T02:03:06.00+0800 audit.app.map-route [email protected] 2016-11-24T02:03:03.00+0800 audit.app.create [email protected] instances: 1, memory: 256, state: STOPPED, environment_json: PRIVATE DATA HIDDEN KaiZhaos-MacBook-Pro:~ kaizhao$ Step 16: files - Print out a list of files in a directory or the contents of a specific file of an app running on the DEA backend Reference http://cli.cloudfoundry.org/en-US/cf/files.html

cf files APP_NAME [PATH] [-i INSTANCE] KaiZhaos-MacBook-Pro:~ kaizhao$ cf files Predix-HelloWorld-WebApp-KZ Getting files for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... OK .bash_logout 220B .bashrc 3.6K .profile 675B app/ - logs/ - run.pid 3B staging_info.yml 226B tmp/ - Step 17: Tail or show recent logs for an app Reference http://cli.cloudfoundry.org/en-US/cf/logs.html

cf logs APP_NAME --recent

Page 21: GE Predix 新手入门 赵锴 物联网_IoT

KaiZhaos-MacBook-Pro:~ kaizhao$ cf logs Predix-HelloWorld-WebApp-KZ --recent Connected, dumping recent logs for app Predix-HelloWorld-WebApp-KZ in org Shanghai_Foundry / space [email protected] as [email protected]... 2016-11-24T21:39:01.44+0800 [API/0] OUT Updated app with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 ({"memory"=>512}) 2016-11-24T21:39:03.68+0800 [API/0] OUT Updated app with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 ({"state"=>"STOPPED"}) 2016-11-24T21:39:03.72+0800 [App/0] ERR 2016-11-24T21:39:03.72+0800 [App/0] OUT 2016-11-24T21:39:08.11+0800 [API/0] OUT Updated app with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 ({"state"=>"STARTED"}) 2016-11-24T21:39:08.12+0800 [DEA/5] OUT Starting app instance (index 0) with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 2016-11-24T22:24:40.59+0800 [API/0] OUT Updated app with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 ({"state"=>"STOPPED"}) 2016-11-24T22:24:40.63+0800 [App/0] ERR 2016-11-24T22:24:40.63+0800 [App/0] OUT 2016-11-24T22:24:41.64+0800 [DEA/5] OUT Stopping app instance (index 0) with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 2016-11-24T22:24:41.64+0800 [DEA/5] OUT Stopped app instance (index 0) with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 2016-11-24T22:24:56.52+0800 [API/0] OUT Updated app with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 ({"state"=>"STARTED"}) 2016-11-24T22:24:56.52+0800 [DEA/5] OUT Starting app instance (index 0) with guid 95d878d5-600b-4672-b9ca-5b3a69c615d5 KaiZhaos-MacBook-Pro:~ kaizhao$ Step 18: List all stacks (a stack is a pre-built file system, including an operating system, that can run apps) Reference http://cli.cloudfoundry.org/en-US/cf/stacks.html

cf stacks

KaiZhaos-MacBook-Pro:~ kaizhao$ cf stacks Getting stacks in org Shanghai_Foundry / space [email protected] as [email protected]... OK name description cflinuxfs2 Cloud Foundry Linux-based filesystem KaiZhaos-MacBook-Pro:~ kaizhao$ Step 19: org and space information KaiZhaos-MacBook-Pro:~ kaizhao$ cf orgs Getting orgs as [email protected]...

Page 22: GE Predix 新手入门 赵锴 物联网_IoT

name Shanghai_Foundry KaiZhaos-MacBook-Pro:~ kaizhao$ cf spaces Getting spaces in org Shanghai_Foundry as [email protected]... name [email protected] KaiZhaos-MacBook-Pro:~ kaizhao$ Route: map the domain name to a specific instance. ============================================================ Step 20: List all routes in the current space or the current organization Reference http://cli.cloudfoundry.org/en-US/cf/routes.html

cf routes [--orglevel] KaiZhaos-MacBook-Pro:~ kaizhao$ cf routes Getting routes for org Shanghai_Foundry / space [email protected] as [email protected] ... space host domain port path type apps service [email protected] predix-helloworld-webapp-kz run.xxxx.predix.io Predix-HelloWorld-WebApp-KZ KaiZhaos-MacBook-Pro:~ kaizhao$ Step 21: List domains in the target org Reference http://cli.cloudfoundry.org/en-US/cf/domains.html

cf domains