cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Snap autostart

Snap autostart

osamaayoub
Established Member

Hello,

 

I have a snap that contains three applications that needs to be started in order with sometime in between. What is the best way to autostart these apps and give it the correct order. The autostart should happen when the PLC is started or restarted.

I tried autostart within passthrough, but this seems not to work, maybe I am missing some options that I can't find online either.

 

Thanks in advanced

 

Regards,

Osama

6 REPLIES 6

nickH
Community Moderator
Community Moderator

Hi Osama,

you could try to subsribe to this value in the Data Layer: "plc/app/Application/admin/state/runtime" and check if the plc is running. 

image.png

 

I would suggest to make a fourth application (which runs no matter what) in your snap which watches this value and controls the startup of your other apps. 

 

Best regards, 

Nick 

osamaayoub
Established Member

Hello,

 

Thanks for your reply, I should have mentioned that I am currently working on the virtual core and it seems that this node is not available on the virtual core. Regarding the fourth application, is it the only way to start the other three? Isn't there some commands that I can use in the YAML file to instruct the snap on how to start? Is there an example for autostart that I can check and build on?

 

Regards,

Osama

UPDATE: I was able to start the applications automatically, but this only works after the first installation of the snap, when I reboot the virtual core it shows that the commands are executed when monitoring using "top" command and services are listed as enabled and running, but the applications are actually not running.

Here is the part of my YAML

apps:
  opcserver:
    command: *****************
    daemon: simple
    passthrough:
      restart-condition: always
      restart-delay: 10s  
    plugs:
      - network-bind
  opcuadatalayer:
    command: ***********
    daemon: simple
    passthrough:
      start-timeout: 90s
      restart-condition: always
      restart-delay: 10s  
    plugs: 
      - network
      - datalayer
      - network-bind
  opcuadatalayerclient:
    command: ***************
    daemon: simple
    passthrough:
      start-timeout: 90s
      restart-condition: always
      restart-delay: 10s 
    plugs: 
      - network
      - datalayer
      - network-bind

 

UPDATE: I was able to start the applications automatically, but this only works after the first installation of the snap, when I reboot the virtual core it shows that the commands are executed when monitoring using "top" command and services are listed as enabled and running, but the applications are actually not running.

Here is the part of my YAML

apps:
  opcserver:
    command: *****************
    daemon: simple
    passthrough:
      restart-condition: always
      restart-delay: 10s  
    plugs:
      - network-bind
  opcuadatalayer:
    command: ***********
    daemon: simple
    passthrough:
      start-timeout: 90s
      restart-condition: always
      restart-delay: 10s  
    plugs: 
      - network
      - datalayer
      - network-bind
  opcuadatalayerclient:
    command: ***************
    daemon: simple
    passthrough:
      start-timeout: 90s
      restart-condition: always
      restart-delay: 10s 
    plugs: 
      - network
      - datalayer
      - network-bind

 

nickH
Community Moderator
Community Moderator

Hi Osama,

I'm sorry. I misunderstood your question. When you first said start of the PLC, I thought you are referring to the PLC-App. 

When you define your application as daemon: simple it will get started after installation of the app and also on reboot of the ctrlX CORE. The restart conditions you defined will start the application, in case it gets stopped. 

Some more information on that can be found in the snapcraft yaml reference.

Could you check via command line, if your snap is really not running?

Best regards, 

Nick

 

osamaayoub
Established Member

Thank you for your help. I tried to install the snap on an actual CtrlX and it worked fine using the structure of YAML that is mentioned in the sample programs offered.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist