# Starting the GEV server in a Linux service does not work

**URL:** https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568
**Category:** Tools
**Created:** [December 15, 2021, 6:34pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568 "2021-12-15T18:34:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ASchmitt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/aschmitt/32/827_2.png) [@ASchmitt](https://forum.commonvisionblox.com/u/ASchmitt)
#### Post date: [December 15, 2021, 6:34pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/1 "2021-12-15T18:34:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![c.hartmann](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/c.hartmann/32/247_2.png) [@c.hartmann](https://forum.commonvisionblox.com/u/c.hartmann)
#### Post date: [December 20, 2021, 11:17am UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/2 "2021-12-20T11:17:16Z")

</div>

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?)

---

<div class="post-metadata">

### Author: ![ASchmitt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/aschmitt/32/827_2.png) [@ASchmitt](https://forum.commonvisionblox.com/u/ASchmitt)
#### Post date: [December 20, 2021, 12:59pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/3 "2021-12-20T12:59:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![c.hartmann](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/c.hartmann/32/247_2.png) [@c.hartmann](https://forum.commonvisionblox.com/u/c.hartmann)
#### Post date: [December 20, 2021, 2:02pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/4 "2021-12-20T14:02:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ASchmitt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/aschmitt/32/827_2.png) [@ASchmitt](https://forum.commonvisionblox.com/u/ASchmitt)
#### Post date: [December 20, 2021, 2:18pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/5 "2021-12-20T14:18:52Z")

</div>

😉 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.

---

<div class="post-metadata">

### Author: ![ASchmitt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/aschmitt/32/827_2.png) [@ASchmitt](https://forum.commonvisionblox.com/u/ASchmitt)
#### Post date: [December 20, 2021, 2:20pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/6 "2021-12-20T14:20:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![c.hartmann](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/c.hartmann/32/247_2.png) [@c.hartmann](https://forum.commonvisionblox.com/u/c.hartmann)
#### Post date: [December 21, 2021, 9:01am UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/7 "2021-12-21T09:01:54Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

### Author: ![ASchmitt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/aschmitt/32/827_2.png) [@ASchmitt](https://forum.commonvisionblox.com/u/ASchmitt)
#### Post date: [December 23, 2021, 12:02pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/8 "2021-12-23T12:02:06Z")

</div>

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

```auto
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

```

---

<div class="post-metadata">

### Author: ![ASchmitt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/aschmitt/32/827_2.png) [@ASchmitt](https://forum.commonvisionblox.com/u/ASchmitt)
#### Post date: [December 28, 2021, 4:43pm UTC](https://forum.commonvisionblox.com/t/starting-the-gev-server-in-a-linux-service-does-not-work/1568/9 "2021-12-28T16:43:36Z")

</div>

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

```auto
handle to create GevServer must not be empty

```

no longer occurs.

This is now my service file.

```auto
[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

```
