Skip to content

Create and start application

If you don't want to create any applications or you just want to see some examples, you can download one of the example applications:

Creating application package

Native application

In this tutorial, you will see example application, written in NodeJS, but you can use any type of application you want.

First, you need to create application package structure, e.g.:

├── bin
│   ├── fridge.js
│   ├── node_modules
│   ├── package.json
│   └── package-lock.json
└── conf
    └── conf.yml

bin directory contains all files that your application need.

conf/conf.yml is a file that describes your application. For more information about configuration file, click here.

Example configuration file.:

app:
  name: 'fridge'
  version: '1.0.0'
  appType: 'standard'
  procType: 'native'
  processProvider:
    name: 'GenericOsProcessProviderImpl'
    version: '1.0.0'
    executable:
      start:
        command: 'node ${ont_app_path}/bin/fridge.js --port ${ont_port_1}'
        successLine: 'Listening at port ${ont_port_1}'
  placeHolder:
    name: 'PlaceHolderManagerImpl'
    version: '1.0.0'
  serviceRepository:
    healthCheckUrl: 'http://${address}:${ont_port_1}/isAlive'
    entities:
      - entity:
          priority: 1
          port: ${ont_port_1}
          protocol:
            type: 'HTTP'
            version: '1.1'
          isExternal: true
          isInternal: true

First, you need to provide some basic information about application such as name, version of app, application type and process type.

app:
  name: 'fridge'
  version: '1.0.0'
  appType: 'standard'
  procType: 'native'

Next step is to specify what process provider you want to use.

Then, you need to specify command that starts application. Here you can pass application port. '${ont_port_1}' value will be replaced during the start.

You can specify success line, but it is not obligatory. It determines when application has started. If you don't specify success line, the application instance will be considered as started after 90 seconds (this value can be changed here).

  processProvider:
    name: 'GenericOsProcessProviderImpl'
    version: '1.0.0'
    executable:
      start:
        command: 'node ${ont_app_path}/bin/fridge.js --port ${ont_port_1}'
        successLine: 'Listening at port ${ont_port_1}'

Next is a placeholder manager. It can replace placeholders in your files. You can read more about it here.

  placeHolder:
    name: 'PlaceHolderManagerImpl'
    version: '1.0.0'

The last part of configuration is service repository.

First, you need to specify healthCheckUrl that will be used for determining if application instance is alive. If endpoints returns 200, the application instance is considered alive.

Then you need to specify service repository entities.

You can also decide if your application should be accessible on edge load balancer (isExternal) and inner load balancer (isInternal).

  serviceRepository:
    healthCheckUrl: 'http://${address}:${ont_port_1}/isAlive'
    entities:
      - entity:
          priority: 1
          port: ${ont_port_1}
          protocol:
            type: 'HTTP'
            version: '1.1'
          isExternal: true
          isInternal: true

Docker application

In this tutorial, you will see example with Demo Fridge application docker image, but you can use any image you want.

First, you need to create application package structure, e.g.:

├── bin
└── conf
    └── conf.yml

bin directory contains all files that your application need. In this example you don't need any files because you are using docker image. So you can leave this directory empty.

conf/conf.yml is a file that describes your application. For more information about configuration file, click here.

app:
  name: 'onteon-demo-app-fridge-docker'
  version: '1.0.0'
  appType: 'standard'
  procType: 'docker'
  processProvider:
    name: 'DockerOsProcessProviderImpl'
    version: '1.0.0'
    executable:
      start:
        imageName: 'onteon/demo-app-fridge:1.0.0'
        exposedPort: '${ont_port_1}'
        innerPort: '3000'
        pullNewerImage: false
        successLine: 'Listening at port 3000'
  placeHolder:
    name: 'PlaceHolderManagerImpl'
    version: '1.0.0'
    filesToReplace:
    variables:
  serviceRepository:
    healthCheckUrl: 'http://${address}:${ont_port_1}/isAlive'
    entities:
      - entity:
          priority: 1
          port: ${ont_port_1}
          protocol:
            type: 'HTTP'
            version: '1.1'
          isExternal: false
          isInternal: true

First, you need to provide some basic information about application such as name, version of app, application type and process type.

app:
  name: 'onteon-demo-app-fridge-docker'
  version: '1.0.0'
  appType: 'standard'
  procType: 'docker'

Next step is to specify what process provider you want to use.

Then, you need to specify docker image, inner and exposed ports.

You can specify success line, but it is not obligatory. It determines when application has started. If you don't specify success line, the application instance will be considered as started after 90 seconds (this value can be changed here).

  processProvider:
    name: 'DockerOsProcessProviderImpl'
    version: '1.0.0'
    executable:
      start:
        imageName: 'onteon/demo-app-fridge:1.0.0'
        exposedPort: '${ont_port_1}'
        innerPort: '3000'
        pullNewerImage: false
        successLine: 'Listening at port 3000'

Next is a placeholder manager. It can replace placeholders in your files. You can read more about it here.

  placeHolder:
    name: 'PlaceHolderManagerImpl'
    version: '1.0.0'

The last part of configuration is service repository.

First, you need to specify healthCheckUrl that will be used for determining if application instance is alive. If endpoints returns 200, the application instance is considered alive.

Then you need to specify service repository entities.

You can also decide if your application should be accessible on edge load balancer (isExternal) and inner load balancer (isInternal).

  serviceRepository:
    healthCheckUrl: 'http://${address}:${ont_port_1}/isAlive'
    entities:
      - entity:
          priority: 1
          port: ${ont_port_1}
          protocol:
            type: 'HTTP'
            version: '1.1'
          isExternal: true
          isInternal: true

Package files

If your files are ready, you can package your files into tar.gz. file. Example structures:

fridge-native.tar.gz
├── bin
│   ├── fridge.js
│   ├── node_modules
│   ├── package.json
│   └── package-lock.json
└── conf
    └── conf.yml
fridge-docker.tar.gz
├── bin
└── conf
    └── conf.yml

Upload application

In this part you can:

  • use your application
  • if you are using docker compose you can find example applications in onteon_files/applications/ directory.
  • download example applications. Links can be found at the beginning of this page.

To upload your application, simply execute onteoncli application-registry upload application.tar.gz.

$ onteoncli application-registry upload fridge.tar.gz 
Starting upload session...
Sending part no 0...
Finishing upload session...
uploaded: true

Then, you can check if your application exists with onteoncli application list.

$ onteoncli application list
id                       createdAt                updatedAt                name   version type     processType
616808413dfb6057f7f63733 2021-10-14T10:36:49.063Z 2021-10-14T10:36:49.063Z fridge 1.0.0   standard native

Create application instance

After uploading application, you can create application instance. Before that, you need a few information:

Then you can create application instance with command: onteoncli application-instance create <application-id> <node-id>.

And you can check if application instance was created with command: onteoncli application-instance list

$ onteoncli node list
id                       createdAt                updatedAt                ipAddress  nodeApiPort zoneId status
82292538e6725c2f2741462d 2021-10-14T10:22:03.826Z 2021-10-14T10:44:00.562Z 172.30.0.3 8030        null   available

$ onteoncli application list
id                       createdAt                updatedAt                name   version type     processType
6168135068378c3a666161e5 2021-10-14T10:36:49.063Z 2021-10-14T10:36:49.063Z fridge 1.0.0   standard native

$ onteoncli application-instance create 6168135068378c3a666161e5 82292538e6725c2f2741462d
id:                 5644f06b4b4539840e70f3db
createdAt:          2021-10-14T11:24:30.951Z
applicationName:    fridge
applicationVersion: 1.0.0
applicationId:      6168135068378c3a666161e5
nodeId:             82292538e6725c2f2741462d
status:             created

$ onteoncli application-instance list 
id                       createdAt                applicationName applicationVersion applicationId            nodeId                   status
5644f06b4b4539840e70f3db 2021-10-14T11:24:30.951Z fridge          1.0.0              6168135068378c3a666161e5 82292538e6725c2f2741462d created
1f76f5ae17a7e1d52195cf2d 2021-10-14T11:23:19.924Z nginx-edge      1.0.0              null                     850e7b2c256023aeee83bc72 running
b0e33d9ed3c4950e983be9d6 2021-10-14T11:23:19.872Z nginx-edge      1.0.0              null                     82292538e6725c2f2741462d running
85a0a831289991ab9f8057fd 2021-10-14T11:23:18.85Z  nginx-inner     1.0.0              null                     850e7b2c256023aeee83bc72 running
2388ddcbb2e82617894076cf 2021-10-14T11:23:18.808Z nginx-inner     1.0.0              null                     82292538e6725c2f2741462d running

Start application instance

Start application instance by executing onteoncli application-instance start <application-instance-id>.

If your application has started, you can access it on different urls:

  • Edge load balancer (if isExternal true)
    • http://node-address:8020/_by_name/app-name/
    • http://node-address:8020/_by_name_and_version/app-name/version/
  • Inner load balancer (if isInternal true)
    • http://node-address:8021/_by_name/app-name/
    • http://node-address:8021/_by_name_and_version/app-name/version/
$ onteoncli application-instance start 5644f06b4b4539840e70f3db
start instance described by input:{instanceName=fridge-1.0.0-c3dec6396e5e626-bf2dbfff6c5cd76f824d6c23-1_2021_10_14_11_51_27-bf2dbfff6c5cd76f824d6c23, appName=fridge-1.0.0-c3dec6396e5e626-bf2dbfff6c5cd76f824d6c23}
Listening at port 10000

$ onteoncli application-instance list 
id                       createdAt                applicationName applicationVersion applicationId            nodeId                   status
5644f06b4b4539840e70f3db 2021-10-14T11:24:30.951Z fridge          1.0.0              6168135068378c3a666161e5 82292538e6725c2f2741462d running
1f76f5ae17a7e1d52195cf2d 2021-10-14T11:23:19.924Z nginx-edge      1.0.0              null                     850e7b2c256023aeee83bc72 running
b0e33d9ed3c4950e983be9d6 2021-10-14T11:23:19.872Z nginx-edge      1.0.0              null                     82292538e6725c2f2741462d running
85a0a831289991ab9f8057fd 2021-10-14T11:23:18.85Z  nginx-inner     1.0.0              null                     850e7b2c256023aeee83bc72 running
2388ddcbb2e82617894076cf 2021-10-14T11:23:18.808Z nginx-inner     1.0.0              null                     82292538e6725c2f2741462d running

$ curl http://localhost:8020/_by_name/fridge/api/v1/fridge/1234
[{"name":"Juice","category":"Drink","amount":1790,"unit":"ml"},{"name":"Frankfurter","category":"Meat","amount":1004,"unit":"g"},{"name":"Milk low-fat","category":"Milk","amount":104,"unit":"ml"},{"name":"Gouda","category":"Cheese","amount":493,"unit":"g"},{"name":"Feta","category":"Cheese","amount":950,"unit":"g"},{"name":"Blue cheese","category":"Cheese","amount":674,"unit":"g"},{"name":"Cottage cheese","category":"Cheese","amount":474,"unit":"g"},{"name":"Yoghurt low-fat","category":"Yoghurt","amount":492,"unit":"g"},{"name":"Strawberries","category":"Fruits","amount":227,"unit":"g"}]