Script Instances lost after reboot of ctrlX CORE

Best reply by drschiffler

Hi,

you can use the "init script" functionallity.

  1. Download and unzip the configuration via the web interface
  2. Write a python script 'init.py' with content eg. 'print("Hello ctrlX")' and save it in the configuration in the directory "script" (any other dir/filename would also work)
  3. Zip the configuration directory (now includes the init.py file) and upload it to the core via web ui
  4. Write on the datalyer node "script/cfg/init-script" the payload "{"file": "activeConfiguration/script/init.py","language": "python","parameter": []}" (can be done also via web ui)
  5. Reboot
  6. Now there is always a python instance called "Base" (prerequisite is the python runtime snap)
  7. POST the following payload on "script/instances/Base/cmd/file" to excecute any script you need (via web ui or REST API). Payload eg. '{"name":"activeConfiguration/script/myworker.py","param":[]}'

Notes:

Link to documentation

It seems in the docu linked above is a mistake according to the path for the init script see: activeConfiguration vs. activeSolution

View original
3 replies