17
17
except ImportError :
18
18
from .utils import Callable
19
19
20
- def _make_serverproxy_handler (name , command , environment , timeout , absolute_url , port , check_port , mappath , request_headers_override , rewrite_response ):
20
+ def _make_serverproxy_handler (name , command , environment , timeout , absolute_url , port , mappath , request_headers_override , rewrite_response ):
21
21
"""
22
22
Create a SuperviseAndProxyHandler subclass with given parameters
23
23
"""
@@ -26,10 +26,10 @@ class _Proxy(SuperviseAndProxyHandler):
26
26
def __init__ (self , * args , ** kwargs ):
27
27
super ().__init__ (* args , ** kwargs )
28
28
self .name = name
29
+ self .command = command
29
30
self .proxy_base = name
30
31
self .absolute_url = absolute_url
31
32
self .requested_port = port
32
- self .check_port = check_port
33
33
self .mappath = mappath
34
34
self .rewrite_response = rewrite_response
35
35
@@ -63,7 +63,7 @@ def _realize_rendered_template(self, attribute):
63
63
return self ._render_template (attribute )
64
64
65
65
def get_cmd (self ):
66
- return self ._realize_rendered_template (command )
66
+ return self ._realize_rendered_template (self . command )
67
67
68
68
def get_env (self ):
69
69
return self ._realize_rendered_template (environment )
@@ -115,20 +115,19 @@ def make_handlers(base_url, server_processes):
115
115
116
116
LauncherEntry = namedtuple ('LauncherEntry' , ['enabled' , 'icon_path' , 'title' , 'path_info' ])
117
117
ServerProcess = namedtuple ('ServerProcess' , [
118
- 'name' , 'command' , 'environment' , 'timeout' , 'absolute_url' , 'port' , 'check_port' ,
118
+ 'name' , 'command' , 'environment' , 'timeout' , 'absolute_url' , 'port' ,
119
119
'mappath' , 'launcher_entry' , 'new_browser_tab' , 'request_headers_override' , 'rewrite_response' ,
120
120
])
121
121
122
122
def make_server_process (name , server_process_config , serverproxy_config ):
123
123
le = server_process_config .get ('launcher_entry' , {})
124
124
return ServerProcess (
125
125
name = name ,
126
- command = server_process_config [ 'command' ] ,
126
+ command = server_process_config . get ( 'command' , list ()) ,
127
127
environment = server_process_config .get ('environment' , {}),
128
128
timeout = server_process_config .get ('timeout' , 5 ),
129
129
absolute_url = server_process_config .get ('absolute_url' , False ),
130
130
port = server_process_config .get ('port' , 0 ),
131
- check_port = server_process_config .get ('check_port' , True ),
132
131
mappath = server_process_config .get ('mappath' , {}),
133
132
launcher_entry = LauncherEntry (
134
133
enabled = le .get ('enabled' , True ),
@@ -155,12 +154,16 @@ class ServerProxy(Configurable):
155
154
156
155
Value should be a dictionary with the following keys:
157
156
command
158
- A list of strings that should be the full command to be executed.
157
+ An optional list of strings that should be the full command to be executed.
159
158
The optional template arguments {{port}} and {{base_url}} will be substituted with the
160
159
port the process should listen on and the base-url of the notebook.
161
160
162
161
Could also be a callable. It should return a list.
163
162
163
+ If the command is not specified or is an empty list, it is assumed the process is already
164
+ running, therefore the port checking is skipped and the proxy is set up on the specified
165
+ port.
166
+
164
167
environment
165
168
A dictionary of environment variable mappings. As with the command
166
169
traitlet, {{port}} and {{base_url}} will be substituted.
@@ -177,10 +180,6 @@ class ServerProxy(Configurable):
177
180
port
178
181
Set the port that the service will listen on. The default is to automatically select an unused port.
179
182
180
- check_port
181
- Enable/Disable port availability check. If enabled and port is not available, the proxy will
182
- raise an exception. If disabled, the port availability check is skipped. Default is True.
183
-
184
183
mappath
185
184
Map request paths to proxied paths.
186
185
Either a dictionary of request paths to proxied paths,
0 commit comments