Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set GIT_DISCOVERY_ACROSS_FILESYSTEM to allow service to access git repo stored under a symlink

We have an Upstart service/job that uses a local clone of a git repo. After relocating the data folder using a symbolic link we now get the following error message:

Failed to run 'git fetch' for /var/company/service/src/program repo; Details: fatal: Not a git repository (or any parent up to mount point /data) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

How can I set GIT_DISCOVERY_ACROSS_FILESYSTEM for the service?

like image 700
Greg Bray Avatar asked Mar 08 '23 03:03

Greg Bray


1 Answers

GIT_DISCOVERY_ACROSS_FILESYSTEM is an environmental variable that git looks for when trying to find the root of the repo. If that path exists on another filesystem, the command will produce the above error message to prevent git from crossing filesystem boundaries. You can set the value to true to allow this operation, and most init systems have ways to add environmental variables for a job/service.

For Upstart we just needed to update the /etc/init/servicename.conf file to include env and export keywords:

start on runlevel [2345]
stop on runlevel [^2345]
respawn
respawn limit 10 2
chdir /usr/local/servicename
setgid servicegroup
setuid servicename
limit nofile 1000000 1000000

env GIT_DISCOVERY_ACROSS_FILESYSTEM=true
export GIT_DISCOVERY_ACROSS_FILESYSTEM
exec /usr/local/servicename --cfg /etc/servicename.cfg >> /var/log/servicename.log 2>&1

After reloading the config and restarting the service, the git error message went away.

like image 136
Greg Bray Avatar answered Apr 27 '23 07:04

Greg Bray