Spring write a program pushed to the Cloud Foundry, and try to access from the outside

Content try:

A daemon to write your own, try to push on Cloud Foundry, and open access from outside MindSphere.

Program the following functions:

1, using the API MindSphere provided to obtain the specified timing Token

2, the timing of start task pulls data from the timing data, and print the log.

3, there is provided a REST interface, used to obtain the data.

4, proceeding log log, print to Cloud Foundry container.

 

Prerequisites:

1, the computer has installed Power Shell.

2, ahead of good programming to be tested.

3, has MindSphere the Developer account.

 

Operating with the mind:

(A) programming

Program address: https://github.com/quchunhui/demo-macket/tree/master/mindsphere

 

(B) landed Cloud Foundry

Cloud Foundry's landing, you can refer to on a blog.

Blog address: https://www.cnblogs.com/quchunhui/p/12015167.html

 

(C) create space and give permission CF

1, switching to an existing tissue (ORG), related commands is as follows:

Switching organization: cf target -o rexelcn0

 

 

 

2, space is created to run the test program (space), related command is as follows:

Creating space: cf create-space rexel-mf-api-test 

View all space: cf spaces

 

 

 

3, Role updated space (role) and Permission (permission), related command is as follows:

Space in the view of users and their rights: cf space-users rexelcn0 rexel-mf-api-test

 

 

 

 

Additional:

If you want to use a different account, a subsequent operation, you can use the following command to add permissions.

Add SpaceManager permissions for the specified user: cf set-space-role [email protected] rexelcn0 rexel-mf-api-test SpaceManager

Add SpaceDeveloper permissions for the specified user: cf set-space-role [email protected] rexelcn0 rexel-mf-api-test SpaceDeveloper

 

 

 

(D) the application is deployed to Cloud Foundry

1. Create manifest.yml file in the root directory of the program

Document reads as follows:

---
applications:
- name: rexel-mindsphere-api-test
  instances: 1
  random-route: true
  path: target/rexel-mindspere-api-0.0.1.jar
  memory: 512M  

  

2, the program space to push the CF, perform the following commands:

Jump into Spaces: cf target -s rexel-mf-api-test

Jump into the root directory: cd D: \ MyWork \ 22_Github \ rexel-cn \ rexel-jarvis \ rexel-mindsphere-api

Push program: cf push

List all applications and operating states: cf apps

View detailed status of the application: cf app rexel-mf-api-test

 

 

 

[Episode 1]

When executed cf push being given an error

 

 

Use mvn package in the root directory of the program recompiled package, and then do problem solving after cf push again.

 

[Episode 2]

After the program upload, cf prompts a boot failure

 

 

 

Follow the prompts of the command to view the log. Command: cf.exe logs rexel-mindsphere-api-test --recent

You can see the prompt enough memory.

 

 

 

尝试将manifest.yml中配置的内存大小调高,重新推送之后解决。修改之后的manifest.yml文件内容

---
applications:
- name: rexel-mindsphere-api-test
  instances: 1
  random-route: true
  path: target/rexel-mindspere-api-0.0.1.jar
  memory: 1G 

  

 

 

 

(五)SSH进入到空间查看运行

官网操作手册:https://developer.mindsphere.io/zh/paas/paas-cloudfoundry-ssh.html

 

 

1、检查空间SSH是否开启

命令:cf space-ssh-allowed rexel-mf-api-test

2、开始指定空间SSH权限:

默认是开启的,如果没有开启,可以使用以下命令打开权限。

命令:cf allow-space-ssh rexel-mf-api-test

3、为应用开启SSh权限:

命令:cf enable-ssh rexel-mindsphere-api-test

注意不要弄错了空间名(rexel-mf-api-test)和应用名(rexel-mindsphere-api-test)

4、重新启动应用:

命令:cf restart rexel-mindsphere-api-test

5、SSH进入应用空间:

命令:cf ssh rexel-mindsphere-api-test

 

6、进入日志所在路径:

在spring程序的logback中,配置的日志路径为:/home/vcap/logs

进入路径:cd /home/vcap/logs/

 

 7、查看日志是否正常:

命令:less rexel-md-test2019-12-11.log

 

 

 

Cloud Foundry

Guess you like

Origin www.cnblogs.com/quchunhui/p/12024493.html