Querying Status of Custom App from Node-Red.
Home › Forums › Conduit: AEP Model › Querying Status of Custom App from Node-Red.
Tagged: Custom App, Node-RED
- This topic has 6 replies, 2 voices, and was last updated 7 years, 11 months ago by
Ajay K.
-
AuthorPosts
-
May 4, 2017 at 4:31 pm #18933
Ajay K
ParticipantI have installed a custom App and it shows up in the Apps section in the Conduit Admin ui screen. There is a button there to Start & Stop the custom App. I was hoping to do the same from the node-red application. How can I query the status of the custom application (in terms of running/stopped) and mimic the same behavior of the button on the App.html web page.
I am just asking in the interest of saving time and not re-inventing the wheel on trying to implement the same functionality from node-red?
Thanks,
AjayMay 5, 2017 at 8:00 am #18937Jeff Hatch
KeymasterAjay,
Details on the status of a custom application integrated with the Custom Application Management in Conduit can be found here:
The status.json file is what is being read by the Web UI for the status information.
You can start and stop your application you can use app-manager:
app-manager –command start –appId
Or you could execute the Start script directly from your application.
Jeff
May 5, 2017 at 9:58 am #18938Ajay K
ParticipantThanks Jeff for your response. I was hoping the start/stop was being executed via one of the AEP Web API Command endpoints. So currently the Web UI uses the app-manager to start and stop the application?
Thanks,
AjayMay 5, 2017 at 10:52 am #18939Jeff Hatch
KeymasterAjay,
There is an API entry point at api/customApps in the Web UI. Here is an example of stopping an app:
admin@mtcdt:/var/config# curl -X POST -H ‘Content-Type: application/json’ -d ‘{}’ 127.0.0.1/api/customApps/58a4d0d85b1b015a89000006/stop
{
“code” : 200,
“status” : “success”
}The trick will be to get the appId -> 58a4d0d85b1b015a89000006. You can get that from the output of:
curl -s 127.0.0.1/api/customApps
which will return something like this:
{
“code” : 200,
“result” : [
{
“_id” : “58a4d0d85b1b015a89000006”,
“description” : “Basic web server running on port 3000. Firewall is opened on install. node_modules is included in the tarball. Utilizes all custom app functionality including environment variables, custom status file, config file, and install scripts.”,
“info” : “Listening on port 3000 as of Mon May 01 2017 18:09:18 GMT+0000 (UTC)”,
“name” : “express-hello-world”,
“status” : “STOPPED”,
“version” : “1.4”,
“versionNotes” : “Implement restart and reload in the Start script”
}
],
“status” : “success”
}Jeff
May 5, 2017 at 11:17 am #18940Ajay K
ParticipantHi Jeff,
Thanks so much for taking the time to respond and write out a detailed way to start/stop the custom app. I did try to get the custom App Id based of the suggestion above. I am not sure why though the appId is written out as “LOCAL“. Is that correct? The custom app was installed on the conduit flash.
Thanks,
Ajay.May 5, 2017 at 11:53 am #18941Jeff Hatch
KeymasterAjay,
The LOCAL appID should work to start and stop your application. Since you did a local install, and not from DeviceHQ, your app was assigned the appId of LOCAL. Currently, the way app-manager works, it was intended to only manage one LOCAL app at a time, so if you install a second, you may not get the behavior you want.
In my example, the application was installed by downloading it from DeviceHQ.
Jeff
May 5, 2017 at 12:07 pm #18942Ajay K
ParticipantJeff,
I was able to both start/stop the application from node-red based of the URL you had mentioned earlier and I used the http request node. Also the LOCAL id worked perfectly well.
Thanks once again for your timely responses.
Thanks,
Ajay -
AuthorPosts
- You must be logged in to reply to this topic.