-
Notifications
You must be signed in to change notification settings - Fork 27
/
start-node.sh
executable file
·82 lines (63 loc) · 1.68 KB
/
start-node.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#
# Starts a remote sbatch jobs without port forwarding.
# Sample usage: bash start-node.sh singularity docker://ubuntu
if [ ! -f params.sh ]
then
echo "Need to configure params before first run, run setup.sh!"
exit
fi
. params.sh
if [ ! -f helpers.sh ]
then
echo "Cannot find helpers.sh script!"
exit
fi
. helpers.sh
if [ "$#" -eq 0 ]
then
echo "Need to give name of sbatch job to run!"
exit
fi
NAME="${1:-}"
# The user could request either <resource>/<script>.sbatch or
# <name>.sbatch
SBATCH="$NAME.sbatch"
# Exponential backoff Configuration
# set FORWARD_SCRIPT and FOUND
set_forward_script
check_previous_submit
echo
echo "== Getting destination directory =="
RESOURCE_HOME=`ssh ${RESOURCE} pwd`
ssh ${RESOURCE} mkdir -p $RESOURCE_HOME/forward-util
echo
echo "== Uploading sbatch script =="
scp "${FORWARD_SCRIPT}" "${RESOURCE}:$RESOURCE_HOME/forward-util/"
# adjust PARTITION if necessary
set_partition
echo
echo "== Submitting sbatch =="
SBATCH_NAME=$(basename $SBATCH)
command="sbatch
--job-name=$NAME
--partition=$PARTITION
--output=$RESOURCE_HOME/forward-util/$NAME.out
--error=$RESOURCE_HOME/forward-util/$NAME.err
--mem=$MEM
--time=$TIME
$RESOURCE_HOME/forward-util/$SBATCH_NAME $PORT \"${@:2}\""
echo ${command}
ssh ${RESOURCE} ${command}
# Tell the user how to view error/output logs
instruction_get_logs
# Wait for the node allocation, get identifier
get_machine
echo "job is running on $MACHINE"
sleep 5
echo
echo "== Connecting to resource =="
# Print logs for the user, in case needed
print_logs
echo "Connect to machine:"
echo "ssh -t ${RESOURCE} ssh ${FORWARD_USERNAME}@${MACHINE}"