Combine C++ daemon with Electron app

Hello!

I was wondering if there is any way to use snap in order to package an Electron app alongside with a C++ daemon.

Specifically, I want a daemon to be completely written in C++ (managed by systemd or a manual PID file, with autostart on system boot) to be able to communicate with an Electron UI with some sort of IPC strategy. I’d like to avoid writing a node.js extension at all, just to keep the daemon smaller & faster. I should be able to easily kill the electron UI, but keep the daemon around with main functionality running in background.

My questions are:

  • is there any way to define the two parts in a single snapcraft.yaml file? Is there any way to declare the relations between them at the snap level?
  • can I reuse the daemon functionality snap provides for the C++ part and keep this one separated from the Electron UI?

Disclaimer: I’m a total newbie into the Snapcraft world and most surely I didn’t expressed myself correctly here but thanks for taking the time to read through it!

Thanks in advance for any help!

Hey, snapcraft itself doesn’t know/care what software it’s packaging. Whether it’s a daemon or an Electron app, doesn’t matter to it.

So one part of yours would be the Electron app, another part would be the daemon. Both would be commands, one of which would be a daemon.

I’m not sure if there’s a way to convince electron-builder or electron-forge to bundle a daemon in the snaps they produce, but you can sure get the output from those and dump it into a snap of your own. There will be a bit more to work on in your snapcraft.yaml is all.

Sounds very promising! Thanks for links & direction to take, this will definitely help!

I am in the same boat. I am using patches to change the template snapcraft.yaml hidden in the node_modules and used by electron builder.

Have you looked at using electron-packager? See Snapping Electron Applications with Electron-Packager

I know it exists but not an option for us at the moment.