@@ -168,6 +168,9 @@ def _req_keepvars_default(self):
168168 # Will get the address of the server as reported by job manager
169169 current_ip = Unicode ()
170170
171+ # Will get the port of the server as reported by singleserver
172+ current_port = Integer ()
173+
171174 # Prepare substitution variables for templates using req_xyz traits
172175 def get_req_subvars (self ):
173176 reqlist = [ t for t in self .trait_names () if t .startswith ('req_' ) ]
@@ -346,7 +349,9 @@ def poll(self):
346349 @gen .coroutine
347350 def start (self ):
348351 """Start the process"""
349- self .port = self .server .port = 0
352+ if self .server :
353+ self .server .port = self .port
354+
350355 job = yield self .submit_batch_script ()
351356
352357 # We are called with a timeout, and if the timeout expires this function will
@@ -371,19 +376,19 @@ def start(self):
371376 yield gen .sleep (self .startup_poll_interval )
372377
373378 self .current_ip = self .state_gethost ()
374- while self .port == 0 :
379+ while self .current_port == 0 :
375380 yield gen .sleep (self .startup_poll_interval )
376381
377382 if jupyterhub .version_info < (0 ,7 ):
378383 # store on user for pre-jupyterhub-0.7:
379- self .user .server .port = self .port
384+ self .user .server .port = self .current_port
380385 self .user .server .ip = self .current_ip
381386 self .db .commit ()
382387 self .log .info ("Notebook server job {0} started at {1}:{2}" .format (
383- self .job_id , self .current_ip , self .port )
388+ self .job_id , self .current_ip , self .current_port )
384389 )
385390
386- return self .current_ip , self .port
391+ return self .current_ip , self .current_port
387392
388393 @gen .coroutine
389394 def stop (self , now = False ):
0 commit comments