Skip to content

Commit

Permalink
[rqd] Add new config option RQD_USE_PATH_ENV_VAR. (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainf-ubi authored Jan 27, 2023
1 parent 8a33d83 commit bb74558
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
21 changes: 12 additions & 9 deletions rqd/rqd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Optional configuration file:
----------------------------
in /etc/rqd3/rqd3.conf:
In /etc/opencue/rqd.conf (on Linux) or %LOCALAPPDATA%/OpenCue/rqd.conf (on Windows):
[Override]
OVERRIDE_CORES = 2
OVERRIDE_PROCS = 3
Expand Down Expand Up @@ -89,14 +89,17 @@ def setupLogging():

def usage():
"""Prints command line syntax"""
s = sys.stderr
print("SYNOPSIS", file=s)
print(" ", sys.argv[0], "[options]\n", file=s)
print(" -d | --daemon => Run as daemon", file=s)
print(" --nimbyoff => Disables nimby activation", file=s)
print(" -c => Provide an alternate config file", file=s)
print(" Defaults to /etc/rqd3/rqd3.conf", file=s)
print(" Config file is optional", file=s)
usage_msg = f"""SYNOPSIS
{sys.argv[0]} [options]
-d | --daemon => Run as daemon
--nimbyoff => Disables nimby activation
-c => Provide an alternate config file
On Linux: defaults to /etc/opencue/rqd.conf
On Windows: Defaults to %LOCALAPPDATA%/OpenCue/rqd.conf
Config file is optional
"""
print(usage_msg, file=sys.stderr)


def main():
Expand Down
8 changes: 7 additions & 1 deletion rqd/rqd/rqconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
RQD_RETRY_CRITICAL_REPORT_DELAY = 30
RQD_USE_IP_AS_HOSTNAME = True
RQD_USE_IPV6_AS_HOSTNAME = False

# Use the PATH environment variable from the RQD host.
RQD_USE_PATH_ENV_VAR = False

RQD_BECOME_JOB_USER = True
RQD_CREATE_USER_IF_NOT_EXISTS = True
RQD_TAGS = ''
Expand Down Expand Up @@ -111,7 +115,7 @@
SYS_HERTZ = os.sysconf('SC_CLK_TCK')

if platform.system() == 'Windows':
CONFIG_FILE = os.path.expandvars('$LOCALAPPDATA/OpenCue/rqd.conf')
CONFIG_FILE = os.path.expandvars('%LOCALAPPDATA%/OpenCue/rqd.conf')
else:
CONFIG_FILE = '/etc/opencue/rqd.conf'

Expand Down Expand Up @@ -177,6 +181,8 @@
RQD_USE_IP_AS_HOSTNAME = config.getboolean(__section, "RQD_USE_IP_AS_HOSTNAME")
if config.has_option(__section, "RQD_USE_IPV6_AS_HOSTNAME"):
RQD_USE_IPV6_AS_HOSTNAME = config.getboolean(__section, "RQD_USE_IPV6_AS_HOSTNAME")
if config.has_option(__section, "RQD_USE_PATH_ENV_VAR"):
RQD_USE_PATH_ENV_VAR = config.getboolean(__section, "RQD_USE_PATH_ENV_VAR")
if config.has_option(__section, "RQD_BECOME_JOB_USER"):
RQD_BECOME_JOB_USER = config.getboolean(__section, "RQD_BECOME_JOB_USER")
if config.has_option(__section, "RQD_TAGS"):
Expand Down
2 changes: 2 additions & 0 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ def getHostname(self):
@rqd.rqutil.Memoize
def getPathEnv(self):
"""Returns the correct path environment for the given machine"""
if rqd.rqconstants.RQD_USE_PATH_ENV_VAR:
return os.getenv('PATH')
if platform.system() == 'Linux':
return '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
if platform.system() == 'Windows':
Expand Down

0 comments on commit bb74558

Please sign in to comment.