Hello world.
Has anyone had success running the shotgunEventDaemon as a linux (RHEL7) service inside a virtualenv?
So just checking if anyone has done anything fancy? I may put it in Docker but trying to avoid system-wide module installs.
thanks!
kp
I was able to sort this out relatively painlessly by setting up systemd
to run the service. By running the daemon with the virtual env python binary explicitly, this gets most of what I needed. Some minor environment variable $PATH
additions added the required modules from the virtualenv. And then I loaded an EnvironmentFile for the more variable env vars needed by triggers, etc.
Make sure you set the Type to forking
. I had it as simple
without noticing and was going “forking” crazy trying to figure out why it was dying immediately. 
Here’s an example of what I used for anyone in the future. I’m sure there’s better sysadmin foo that could be done here but this works for us.
[Unit]
Description=shotgunEvent Daemon
After=network.target
[Service]
Type=forking
User=sgevents
WorkingDirectory=/usr/local/shotgun/shotgunEvents/src/
VIRTUAL_ENV=/path/to/virtualenvs/shotgunEvents-Ni70a7Xr
EnvironmentFile=/etc/shotgun/shotgunEventDaemon.env
Environment=PATH=$VIRTUAL_ENV/bin:$PATH
Environment=PYTHONPATH=$VIRTUAL_ENV/lib/python3.8/site-packages:$VIRTUAL_ENV/src/shotgun-api3
ExecStart=/path/to/virtualenvs/shotgunEvents-Ni70a7Xr/bin/python shotgunEventDaemon.py start
ExecStop=/path/to/virtualenvs/shotgunEvents-Ni70a7Xr/bin/python shotgunEventDaemon.py stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
5 Likes
Awesome, thanks for sharing!