Skip to content

Commit

Permalink
add unix-socket support
Browse files Browse the repository at this point in the history
  • Loading branch information
goebbert1 committed Jan 1, 2025
1 parent 216d9e5 commit a7db69b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions jupyter_rsession_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_system_user():
return(user)

def setup_rserver():
def _get_env(port):
def _get_env(port, unix_socket):
return dict(USER=get_system_user())

def db_config(db_dir):
Expand Down Expand Up @@ -83,7 +83,7 @@ def _get_www_frame_origin(default="same"):
except Exception:
return default

def _get_cmd(port):
def _get_cmd(port, unix_socket):
ntf = tempfile.NamedTemporaryFile()

# use mkdtemp() so the directory and its contents don't vanish when
Expand All @@ -95,7 +95,6 @@ def _get_cmd(port):
get_rstudio_executable('rserver'),
'--auth-none=1',
'--www-frame-origin=' + _get_www_frame_origin(),
'--www-port=' + str(port),
'--www-verify-user-agent=0',
'--secure-cookie-key-file=' + ntf.name,
'--server-user=' + get_system_user(),
Expand All @@ -109,6 +108,14 @@ def _get_cmd(port):
if _support_arg('database-config-file'):
cmd.append(f'--database-config-file={database_config_file}')

if unix_socket != "":
if _support_arg('www-socket'):
cmd.append('--www-socket={unix_socket}')
else:
raise NotImplementedError(f'rstudio-server does not support requested socket connection')
else:
cmd.append('--www-port={port}')

return cmd

def _get_timeout(default=15):
Expand All @@ -127,6 +134,9 @@ def _get_timeout(default=15):
'icon_path': get_icon_path()
}
}
if os.getenv('RSERVER_USE_SOCKET'):
server_process['unix_socket'] = True

return server_process

def setup_rsession():
Expand Down

0 comments on commit a7db69b

Please sign in to comment.