Skip to main content

Run a Built Application

Once you have successfully built an application, either a single-file source code application or one stored in a GitHub repository, you can run it on the Signaloid Cloud Compute Engine via an API request.

Prerequisites

Use the BuildID of a successful build from the Signaloid Cloud Compute Engine to run the built application via the API. See here for more details on how to use the API to build a single-file application and here for a GitHub repository application. Use the BuildID to run the application multiple times without having to spend time rebuilding.

Submit the task to the API

Submit the task request to the Signaloid API via a POST request to builds/{BuildID}/tasks. Optionally, you can set DataSources and Arguments to the post request. For example, assuming that your Signaloid user id is usr_20f7632ffac04b658180b23fe13aab56, you can add set DataSources, like

"DataSources": [
{
"Location":"sd0",
"ResourceID":"signaloid-cloud-storage:/usr_20f7632ffac04b658180b23fe13aab56",
"ResourceType":"SignaloidCloudStorage"
}
]

to mount your Signaloid Cloud Storage at sd0/. If not provided, the Signaloid Cloud Compute Engine will default to the DataSources and Arguments you have set as default config during the build step.

The code snippet below shows how to submit the task request to the API using the axios library.

// Build id you got back after submitting build to SCCE API
const buildID = buildIDFromResponse || "bld_yourSignaloidBuildID"


console.log("Submitting the task to the API...");
let taskPostResponse;
try {
taskPostResponse = await signaloidClient.post(`builds/${buildID}/tasks`);

if (taskPostResponse.data.TaskID) {
console.log(`...task successfully created with ID: ${taskPostResponse.data.TaskID}`);
}
} catch (error) {
console.log("Error:", error);
}

If the task is valid, and the API has accepted the request, the taskPostResponse variable will contain information about the task. The code snippet below shows the contents of the taskPostResponse variable after the task has been successfully created.

{
"TaskID": "tsk_6dcae4d1c4f585901efa12a89a063996"
}

You can now use the TaskID to retrieve the status and outputs of the task from the API.