Custom App not starting automatically after installation/reboot [MTCAP-L4E1]

Home Forums General Custom App not starting automatically after installation/reboot [MTCAP-L4E1]

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #31280
    Rafael
    Participant

    Hi,

    We have a node application that runs on multiple MTCAP-LEU1 (firmware v1.7.4) as a custom app. But now we’re having problems when installing it on a MTCAP-L4E1 (firmware v5.0.1-AEP) using deviceHQ.

    I can see that the app files were downloaded in /var/config/app/app-name but the application is not running automatically after restarting the gateway. It works as expected on MTCAP-LEU1 (v1.7.4) and we didn’t change the code.

    I can run the app manually with the following commands:

    ./Start start

    sudo ./Start start

    sudo app-manager --command start --appid <APPID>

    Output of sudo app-manager --command status:

    {
    	"Apps" : 
    	[
    		{
    			"AppDescription" : "...",
    			"AppId" : "<APPID>",
    			"AppInfo" : "Installed by -",
    			"AppName" : "app-name",
    			"AppType" : "CUSTOM",
    			"AppVersion" : "8.3",
    			"AppVersionNotes" : "...",
    			"Enabled" : true,
    			"status" : null
    		}
    	]
    }

    Output of sudo app-manager --command list-installed:

    {
       "Apps" : []
    }

    Logs in /var/logs/messages:

    annexcd: [INFO] delivery_agent.cc:RunnableCore:3437: sending active apps                                                              
    annexcd: [INFO] mts_device_interface.cc:getActiveApps:541: Node-red disabled so skipping node-red apps                                
    after-switch-inet: restarting annex client                                                                                            
    APPMANAGER: AppCommand::executeStatus: Getting app statuses                                                                           
    APPMANAGER: AppCommand::getBasePathFor: unknown app type. Defaulting to custom                                                        
    APPMANAGER: AppCommand::executeStatus: can't read pid as a string, trying as number:#012 in Json::Value::asCString(): requires stringV
    APPMANAGER: Exiting with success status                                                                                               
    annexcd: [ERR] delivery_agent.cc:FillActiveApps:1042: field [status] missing from ActiveApp  - skipping                               
    annexcd: [INFO] delivery_agent.cc:SendActiveApps:987: Sending Active Apps data

    Permissions of the custom app files:

    -rwxrwxrwx 1 root root

    Permissions of the config file:

    -rw-r--r-- 1 root root

    And I can see our application in the list of custom apps in the gateway UI (custom apps are enabled).

    Any ideas on how to solve this problem?

    Thanks,

    Rafael

    #31281
    Jeff Hatch
    Keymaster

    Hello Rafael,

    Could you do a “cat /var/config/AppManager.json” and let me know what is in that file?

    Thank You,

    Jeff

    #31282
    Rafael
    Participant

    Hi Jeff,

    Here it is:

    admin@mtcap:~$ cat /var/config/AppManager.json
    {
    	"Apps" : 
    	[
    		{
    			"AppDescription" : "...",
    			"AppId" : "<APPID>",
    			"AppInfo" : "Not Available",
    			"AppName" : "app-name",
    			"AppType" : "CUSTOM",
    			"AppVersion" : "8.3",
    			"AppVersionNotes" : "...",
    			"Enabled" : true
    		}
    	]
    }

    Thank you,

    Rafael

    #31283
    Jeff Hatch
    Keymaster

    Hello Rafael,

    It doesn’t appear that the SDCard value is defined in the application manifest file, so it should be installed on an SD Card. Is that correct? We need to verify where it got installed to.

    Do you have any logging from when you ran the “sudo app-manager –command start –appid ” command? The only output I see that you captured from app-manager looks like it is running the status command and having difficulty finding the status.json file. Possibly because the app isn’t where it expects it to be.

    Jeff

    #31284
    Rafael
    Participant

    Hi Jeff,

    We don’t use an SDCard and the application is installed in: /var/config/app/app-name.

    Output of the app-manager start command:

    admin@mtcap:~$ sudo app-manager --command start --appid APPID
    Password: 
    AppCommand::executeStartScript: executing: /var/config/app/app-name/Start start

    After that, the application runs correctly and there are no more logs. But it doesn’t run in the background. After running the start command, I can’t use the terminal anymore. I don’t know if that’s normal, in the Start script we run the node app using nohup.

    Thanks,

    Rafael

    • This reply was modified 4 years ago by Rafael.
    • This reply was modified 4 years ago by Rafael.
    • This reply was modified 4 years ago by Rafael.
    #31288
    Jeff Hatch
    Keymaster

    Hello Rafael,

    In the Start script, what does the command that starts the application look like?

    Jeff

    #31289
    Rafael
    Participant

    It only runs another shell script:

    
    function ExecuteStart {
        echo "ExecuteStart:"
        ./run-app
    }
    

    And run-app looks like this:

    nohup node app.js &

    Thanks,

    Rafael

    #31290
    Jeff Hatch
    Keymaster

    Hello Rafael,

    I think that by executing the “run-app” script in the foreground it may be what is causing the app to not go into the background when executed at the command line. Try running “run-app” in the background, ie “run-app &”. Let’s see if that “fixes” the execute at the CLI behavior.

    It is odd, but I have seen some interesting behavior between processes and deadlocks with non-backgrounded processes and also with running backgrounded process where the app’s pipes (stdout and stderr) were not redirected to /dev/null. By trying to run with the something like the following: “node app.js > /dev/null 2>&1 &” it might help cause all the pipes to be “disconnected” between the parent and child processes.

    Jeff

    #31291
    Rafael
    Participant

    Ok, so I did what you said: run-app & in the Start script and node app.js > /dev/null 2>&1 & in the run-app script. And now, after starting the app with app-manager, it runs in the background:

    
    admin@mtcap:/var/config/app/app-name$ sudo app-manager --command start --appid APPID
    AppCommand::executeStartScript: executing: /var/config/app/app-name/Start start
    Success!
    admin@mtcap:/var/config/app/app-name$
    

    And these are the logs in /var/log/messages:

    
    2020-10-30T19:24:26.319473+00:00 mtcap APPMANAGER: AppCommand::getBasePathFor: unknown app type. Defaulting to custom
    2020-10-30T19:24:26.319976+00:00 mtcap APPMANAGER: AppCommand::getBasePathFor: unknown app type. Defaulting to custom
    2020-10-30T19:24:26.320385+00:00 mtcap APPMANAGER: AppCommand::getBasePathFor: unknown app type. Defaulting to custom
    2020-10-30T19:24:26.333177+00:00 mtcap APPMANAGER: AppCommand::executeStartScript: executing: /var/config/app/app-name/Start start
    2020-10-30T19:24:26.477978+00:00 mtcap APPMANAGER: AppDataDB::SetAppData: updating app info in /var/config/AppManager.json with appId: APPID
    2020-10-30T19:24:26.486483+00:00 mtcap APPMANAGER: Exiting with success status
    

    But the application still doesn’t start after rebooting the gateway (our main problem). Any other ideas on how to solve this problem?

    Thanks,

    Rafael

    #31294
    Jeff Hatch
    Keymaster

    Hello Rafael,

    I did find one interesting difference between starting the app by hand at the command line and through the init script on boot. On boot the /etc/init.d/customapp script sets the –initd flag when executing the app-manager program. This would have the effect of causing the Start script to get executed as “/var/config/app/app-name/Start start –initd”. If that messes up the argument processing on the Start script maybe that is causing a problem.

    Jeff

    #31710

    Looking for more information and we get from this site. https://slimsoupdiet.com/

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.