Skip to content

Commit 0478508

Browse files
committed
Merge branch 'slurm_script'
2 parents e8a0279 + dff4482 commit 0478508

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

batchspawner/batchspawner.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ class BatchSpawnerBase(Spawner):
115115
help="Other options to include into job submission script"
116116
).tag(config=True)
117117

118+
req_prologue = Unicode('', \
119+
help="Scipt to run before single user server starts."
120+
).tag(config=True)
121+
122+
req_epilogue = Unicode('', \
123+
help="Scipt to run after single user server end."
124+
).tag(config=True)
125+
118126
req_username = Unicode()
119127
@default('req_username')
120128
def _req_username_default(self):
@@ -504,8 +512,12 @@ class SlurmSpawner(UserEnvMixin,BatchSpawnerRegexStates):
504512
{% endif %}{% if nprocs %}#SBATCH --cpus-per-task={{nprocs}}
505513
{% endif %}{% if options %}#SBATCH {{options}}{% endif %}
506514
515+
trap 'echo SIGTERM received' TERM
516+
{{prologue}}
507517
which jupyterhub-singleuser
508-
{{cmd}}
518+
srun {{cmd}}
519+
echo "jupyterhub-singleuser ended gracefully"
520+
{{epilogue}}
509521
""").tag(config=True)
510522
# outputs line like "Submitted batch job 209"
511523
batch_submit_cmd = Unicode('sudo -E -u {username} sbatch --parsable').tag(config=True)

0 commit comments

Comments
 (0)