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
To run a built appication via the Signaloid API, you need to have the Build ID of a succesful build on the Signaloid Cloud Compute Engine. See here for more details on how to programmatically build a single-file source code application or here for an application stored in a GitHub repository. Similar to how you would run a compiled binary in a typical operating system, you can use the Build ID to run your application on an arbitrary amount of times on the Signaloid Cloud Compute Engine.
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.
- TypeScript
- cURL
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.
{
"data": {
"TaskID": "tsk_6dcae4d1c4f585901efa12a89a063996",
},
"status": 202,
"statusText": "Accepted",
[...other response keys omitted]
}
You can now use the TaskID
to retrieve the status and outputs of the task from the API.
The code snippet below shows how to submit the task request to the API using curl
.
# API token generated from signaloid.io/settings/api
# buildID="bld_yourSignaloidBuildID"
# Optinal request body. Can submit request without it if you have correctly specified the config on build step
taskObject='{
"Arguments": ""
}'
taskEndpointResponse=$(curl -s --request POST --location "https://api.signaloid.io/builds/$buildID/tasks" \
--header "Content-Type: application/json" \
--header "Authorization: $signaloidAPIKey" \
--data "$taskObject")
echo $taskEndpointResponse
If the task is valid, and the API has accepted the request, the taskEndpointResponse
variable will contain information about the task. The code snippet below shows the contents of the taskEndpointResponse
variable after the task has been successfully created.
{
"data": {
"TaskID": "tsk_6dcae4d1c4f585901efa12a89a063996",
},
"status": 202,
"statusText": "Accepted",
[...other response keys omitted]
}
The TaskID
will allow you to retrieve the status and outputs of the task from the API.