Getting Started
The open web service Web Runner enables you to run custom code in Eyevinn Open Source Cloud and provides a way to glue other open web services together. Orchestrate media workflows, provide custom webhooks, or deploy a custom web application online, and much more. Deploy your Node application from your public or private GitHub repository and make it instantly available. This tutorial walks you through how to get started deploying your web application with Eyevinn Open Source Cloud.
Prerequisites
- If you have not already done so, sign up for an OSC account.
Create web runner
Navigate to the open web service Web Runner in the OSC web console.
If the source code is on a private GitHub repository you need to first generate a GitHub personal access token and store it in as a service secret in Open Source Cloud first.
To launch your web application click on the tab "My web-runners" and then on the button "Create web-runner".
Enter the URL to your source code. It can be an URL to a GitHub repository or an S3 URL. If your GitHub repository is private you also need to enter a reference to the secret you created.
Instance Settings
Field | Description | Example Value |
---|---|---|
Name | The name of your Web Runner instance. | guide |
SourceUrl | The S3 URL to your source code in a zip file or the URL to your GitHub repository containing the application code. | s3://code/my-app.zip |
GitHubToken | A token used to authenticate access to the GitHub repository (optional). | |
AwsAccessKeyId | Access Key Id for S3 access (required when source is on S3 bucket). | birme |
AwsSecretAccessKey | Secret Access Key for S3 access (required when source is on S3 bucket). | {{secret.secretaccesskey}} |
AwsRegion | AWS Region for S3 access. | |
S3EndpointUrl | S3 Endpoint URL when S3 bucket on on AWS. | https://eyevinnlab-birme.minio-minio.auto.prod.osaas.io |
OscAccessToken | (Optional) Access token required if the Web Runner needs to interact with other Eyevinn OSC services. | {{secrets.osctoken}} |
ConfigService | (Optional) The name of your Application Config Service instance used to configure the app. | name-of-configure-service-instance |
When setting up your instance, you are also able to enter OscAccessToken
and ConfigService
- these are both optional parameters. OscAccessToken is a personal access token you need to set if the code you want to run in your Web Runner interacts with other Eyevinn Open Source Cloud services. If you wish to set the OscAccessToken
, you can locate it in your user settings in Eyevinn Open Source Cloud, under the "API" tab.
|
|
If you have created an instance of the Application Config Service and wish to use it to provide configuration for the application in your Web Runner, enter the name you gave the Config Service instance when creating it into the ConfigService
field when creating your Web Runner. To learn more about configuring your Web Runner application, see the section below.
When you have entered the settings you want for your Web Runner instance, press "Create", and you will soon have an instance of your application running.
Now you have deployed an instance of your application. This instance will listen to file events on a MinIO bucket and create a VOD transcoding job when a new file is created.
Configuring your application
To provide configuration to your application, you can use the Application Config open web service. With this service, you can manage configuration values and get the configuration values through the API it provides.
Provided as Environment Variables
When the Web Runner starts, it will look up an Application Config Service instance with the config service name provided when creating the Web Runner instance. If it is found, it will load the configuration values as environment variables. In the example above, it will add the following environment variables:
AWS_ACCESS_KEY_ID=admin
CHANNELURL=https://eyevinnlab.ce.prod.osaas.io/channels/mychannel/master.m3u8
These are now available in your application code process.env.CHANNELURL
.
Manually fetch the config value
To manually fetch a configuration during run time, it can be done by accessing the config service API. Example code below to obtain the URL to a stream that is stored in the config value channelurl
provided by the Application Config instance called tvappconfig
.
mport { Context } from "@osaas/client-core";
import { getEyevinnAppConfigSvcInstance } from "@osaas/client-services";
let configUrl: string | undefined = undefined;
export async function getChannelUrl() {
const ctx = new Context();
if (!configUrl) {
const configService = await getEyevinnAppConfigSvcInstance(ctx, 'tvappconfig');
configUrl = configService.url;
}
const response = await fetch(new URL('/api/v1/config/channelurl', configUrl), {
cache: 'no-store'
});
if (response.ok) {
const data = await response.json();
return data.value;
}
return undefined;
}
Source Code on S3 bucket
Source code can be packaged into a zip file and uploaded to an S3 bucket. To create the zip file go to the projects directory and run.
% zip -r ../my-app.zip ./
Copy this file to the S3 bucket and then provide S3 URL and access credentials when creating the web runner.
Source Code on a private GitHub repository
Create a GitHub personal access token
To access your GitHub repository, you need to create a GitHub Personal Access Token first.
- Verify your email address, if it hasn't been verified yet.
- In the upper-right corner of any page on GitHub, click your profile photo, then click "Settings".
- In the left sidebar, click "Developer settings".
- In the left sidebar, under "Personal access tokens", click "Tokens (classic)".
- Select "Generate new token", then click "Generate new token (classic)".
- In the "Note" field, give your token a descriptive name.
- To give your token an expiration, select "Expiration", then choose a default option or click "Custom" to enter a date.
- Select the scopes you'd like to grant this token. To use your token to access repositories from the command line, select "repo". A token with no assigned scopes can only access public information. For more information, see Scopes for OAuth apps.
- Click "Generate token" and copy it to the clipboard.
Store token as a Service Secret
Now navigate to the Web Runner service in the Eyevinn Open Source Cloud platform. Click on the tab "Service Secrets" and click on the button "New Secret". Give the secret a name and paste the GitHub token from your clipboard.