Built an app with snap daemon which is inactive

Here is my snap.

    adapter: full
    command: usr/bin/MyApp
      - bin/desktop-launch
    daemon: simple
    restart-condition: always
    plugs: [home, unity7, x11, network, network-bind]

When I install snap, my service is enabled but inactive and whenever I restart or start it with enable option it is inactive again.

I install snap using below command:

sudo snap install HelloWorld --dangerous

after installing snap, MyApp is enabled and inactive, I got logs using sudo snap logs HelloWorld.MyApp and it shows:

2021-10-24T08:35:42Z HelloWorld.MyApp[495340]: realpath: '': No such file or directory
2021-10-24T08:35:42Z HelloWorld.MyApp[495342]: realpath: '': No such file or directory
2021-10-24T08:35:42Z HelloWorld.MyApp[495344]: realpath: '': No such file or directory
2021-10-24T08:35:43Z HelloWorld.MyApp[495277]: "Connector         :  Start MyApp Service Version - Sun M10 24 12:05:43 2021"
2021-10-24T08:35:43Z systemd[1]: snap.HelloWorld.MyApp.service: Succeeded.
2021-10-24T08:35:43Z systemd[1]: snap.HelloWorld.MyApp.service: Scheduled restart job, restart counter is at 5.
2021-10-24T08:35:43Z systemd[1]: Stopped Service for snap application HelloWorld.MyApp.
2021-10-24T08:35:43Z systemd[1]: snap.HelloWorld.MyApp.service: Start request repeated too quickly.
2021-10-24T08:35:43Z systemd[1]: snap.HelloWorld.MyApp.service: Failed with result 'start-limit-hit'.
2021-10-24T08:35:43Z systemd[1]: Failed to start Service for snap application HelloWorld.MyApp.

It’s inactive because it either fails to start and exits, or simply just exits after your code is done running. If you want the daemon to remain active, you need to fix your code to run continuously with an event loop. restart-condition: always doesn’t mean systemd will try to start it forever. It gives up if your service is consistently exiting after each start attempt.