Starting the GEV server in a Linux service does not work

When I program a GEV server in C++ it runs without problems on the Linux system (Ubuntu 20.04 ARM 64 bit).
When I create a service to start it, the error
handle to create GevServer must not be empty comes up.
Please let me know if you need a more detailed description of the GEV server sample code and the procedure for creating a service.

Who starts this service? root? Because this might be the issue.

CVB loads a bunch of env vars via login (i.e. /etc/profile.d/cvb_evironment.sh), please verify these are present for your service.

And the service discussed in the other topic might be problematic.
(i assume this is an old topic, i.e. solved, since there is a newer one?)

Hi @c.hartmann ,
This is a different System, the installation went fine and the GEV Server is running without an issue, if I am starting them by hand.
I will try to start the Server as admin and try it, if that can fix the error.
How I can make the cvb_environment.sh present for my service?
Besides the service Problem, the GEV Server is also not working, if I start them with crontab as an admin.

Hi @ASchmitt,
that’s what i meant, a crontab will not (atleast this is what i assume) have the env variable exported like a normal user.
Could you check? I.e. whether the environment vars in cvb_environment.sh are set for your service/crontask.

Just a hint: CVB is designed to be used as a normal user, you should never need admin rights on linux, neither will it improve things xD.

:wink: You mentioned the root rights. I have the Gev otherwise also always started with user rights. But I had also tried it with root rights, because this sometimes solves handel problems.

How can I check this? Did I have to Include the path to the cvb_environment.sh in my environment vars?

Hi,

just in any way you prefer*, cvb_environment.sh simply exports some variables, which are needed by cvb.

*i.e. print them to any log/file at service start.

This is the usual list:

CVB=/opt/cvb
CVBDATA=/var/opt/cvb
CVBCONFIG=/etc/opt/cvb
CVGENICAM_REGISTRY=/var/opt/cvb/Registry
GENICAM_CACHE_V3_1=/var/opt/cvb/genicam
GENICAM_GENTL64_PATH=/opt/cvb/drivers/genicam

Okay, now that might get a little more coplicitous.
So I have created a service that starts a Python program.
This Python program is in turn a web server, which in turn should start the GEVServer, which was written in C++. If I start the webserver by hand, then this also works without problems, the GEVServer is started and runs excellent only if I try to start the whole thing as a service there are problems.
I am not a professional in the use of Linux services and unfortunately do not know how to make the cvb_environment.sh properly accessible to the service.
My service script looks like this

vi /home/pi/Programms/webSkript/app.service
 
[Unit]
Description=Raspberry Gev Kamera Service
After=network-online.target
 
[Service]
ExecStart=/usr/bin/python3 /home/pi/Programms/webSkript/app.py
WorkingDirectory=/home/pi/Programms/webSkript/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
 
[Install]
WantedBy=multi-user.target

By adding the parameters as environment variables in the section [Service], as already described, everything works now.
The error

handle to create GevServer must not be empty

no longer occurs.

This is now my service file.

[Unit]
Description=Raspberry Gev Kamera Service
After=network-online.target
 
[Service]
Environment=CVB=/opt/cvb
Environment=CVBDATA=/var/opt/cvb
Environment=CVBCONFIG=/etc/opt/cvb
Environment=CVGENICAM_REGISTRY=/var/opt/cvb/Registry
Environment=GENICAM_CACHE_V3_1=/var/opt/cvb/genicam
Environment=GENICAM_GENTL64_PATH=/opt/cvb/drivers/genicam
ExecStart=/usr/bin/python3 /home/pi/Programms/webSkript/app.py
WorkingDirectory=/home/pi/Programms/webSkript/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
 
[Install]
WantedBy=multi-user.target
2 Likes