How do I connect interface before start demon

When I installed my snap application, it timeout while trying to start the daemon because cannot access /run/systemd/notify and daemon-notify was not connected. I read some topics but I don’t understand exactly how to do it

apps:
  app:
    command-chain: &_command-chain
      - bin/wayland-launch
      - bin/dbus-launch
      - snap/command-chain/alsa-launch
    command: &_command usr/bin/wrapper
    plugs: &_plugs
      - alsa
      - opengl
      - wayland
      - browser-support
      - hardware-observe
      - network
      - network-bind
      - process-control
      - camera
      - pulseaudio
      - log-observe
      - network-control
      - raw-usb
      - audio-playback
      - audio-record
      - network-manager
      - network-manager-observe
      - network-observe
      - network-setup-control
      - network-setup-observe
      - network-status
      - power-control
      - home
      - dev
      - system-observe
      - snapd-control
      - system-source-code
      - system-trace
      - core-support
      - shutdown
      - hostname-control
      - timeserver-control
      - time-control
      - timezone-control
      - bluez
      - bluetooth-control
      - display-control
      - daemon-notify
    environment: &_environment
      XDG_DATA_HOME: $SNAP_USER_DATA
      XDG_DATA_DIRS: $SNAP/usr/share
      GTK_USE_PORTAL: 0
      GDK_GL: gles

  daemon:
    daemon: notify
    restart-delay: 1s
    restart-condition: always
    watchdog-timeout: 45s
    command-chain: *_command-chain
    command: *_command
    plugs: *_plugs
    environment: *_environment

you define the daemon: in your snapcraft.yaml as install-mode: disable and then use an interface connect hook to enable it as soon as the interface gets connected… here is an example, the “connect-plug-serial-port” hook will enable the daemon when the connection is established, the snapcraft.yaml below makes it default to be disabled at install:

Thanks this will help me.

I have one more question, but I’m not sure if it’s possible to happen. Because in my Electron JS application, I use Python, but a library that executes the Python code is executed in a child process and I get this error: Got notification message from PID, but reception only permitted for main PID Do you know a way how I can solve this?

… might help with this …

also see the notify argument here:

I already read it but unfortunately, it didn’t help me