Systemd service management on Torizon

I would like to use systemd to automatically manage services on Torizon.

I have installed the systemd package on the target but I cannot invoke a systemd commands and get the following error, for instance :

/phosddvr# systemctl 
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

How can I boot with systemd on Torizon ?

Fabian

Greetings @fdortu,

I’m not sure I understand your question. We already use systemd on TorizonCore by default. Or are you saying you want to use systemd inside a container on TorizonCore?

Best Regards,
Jeremias

Dear Jeremias,

Yes indeed, I mean inside a container.

Regards,
Fabian

Dear Jeremias,

My real need is not necessarily to use systemd but to start different services as root while my application runs as user torizon.

I need to start /lib/systemd/systemd-udevd -d and /etc/init.d/ueyeusbdrc start (IDS-imaging uEye camera) as root.

This works if I run the container as root (-u 0) and --privileged (I would like to avoid this but I did not find out) and execute the services in CMD of the dockerfile. But then my application runs as root, which is not ideal.

What is the right way to do that ?

Fabian

Let me see if I can understand your use-case here. Running systemd in a container is “possible”, but honestly it probably makes things more complex than you really need.

So your ultimate objective is to start your camera here and use in inside a container. To do this you’re executing /lib/systemd/systemd-udevd -d and /etc/init.d/ueyeusbdrc start. I assume these are what gets your camera detected and then initialized?

Is it the case then that you just need to do this once on system start and that’s it? Or will you need to execute these multiple times while the system is running?

If it’s the case where you only need to execute this once, then why not just have a systemd service that executes this on system start-up. Then when you start your application container, your camera should be up and ready. Or is there a detail here that I’m missing?

Best Regards,
Jeremias

Dear Jeremias,

Indeed, I could probably use systemd directly on the target (and not inside the container), but then I loose the possibility to have all my infrastructure stored as code. How would I deploy the same thing on many target then ? Would I need to make a new image with TorizonCore ?

Best regards,
Fabian

How would I deploy the same thing on many target then ? Would I need to make a new image with TorizonCore ?

You could use our TorizonCore Builder tool to produce a customized TorizonCore image that can then be installed on many devices: TorizonCore Builder Tool - Customizing TorizonCore Images | Toradex Developer Center

Best Regards,
Jeremias