Running code-server on Shaheen

code-server is an opensource alternative to running VS code on a remote machine.
The server instantiates on a remote host and the client can run in a browser. The following has been tested on Ibex’s GPUs node and client in Google Chrome on local workstation.

Step 1

Create a conda environment first. If you want to know how to install conda on Shaheen and create an environment , please refer to https://kaust-supercomputing-lab.atlassian.net/wiki/spaces/Doc/pages/516325377 .

Install code-server in your conda environment:

conda install code-server

Step 2

Next step is to start a code-server on compute node of Shaheen and connect. To do so, we recommend submitting a SLURM job to start the code-server and connect to it via your browser. The jobscript for code-server may look as follows:

Please replace the username and the directory where you conda environment has been created accordingly.

#!/bin/bash #SBATCH --time=00:10:00 source /project/k01/shaima0d/miniconda3/bin/activate ./codeserver export CODE_SERVER_CONFIG=/scratch/shaima0d/tickets/45007/config export XDG_CONFIG_HOME=/scratch/shaima0d/tickets/45007 node=$(/bin/hostname) port=10121 user=$(whoami) gateway=${EPROXY_LOGIN} submit_host=${SLURM_SUBMIT_HOST} if [ -f "config" ] ; then rm config fi echo "bind-addr: ${node}:${port}" >> config echo "auth: password" >> config echo "password: 10DowningStreet" >> config echo "cert: false" >> config echo "Copy the following two lines in a new terminal one after another to create a secure SSH tunnel between your computer and Shaheen compute node." echo "ssh -L ${port}:localhost:${port} ${user}@${submit_host}.hpc.kaust.edu.sa" echo "ssh -L ${port}:${node}:${port} ${user}@${gateway}" code-server --auth=password --user-data-dir=${PWD}/data --extensions-dir=/scratch/shaima0d/code-server/extensions --verbose

The argument --extensions-dir sets the default location where extensions are installed to
Please set the value to a suitable location under /scratch/<your-username>
and make a backup under /project/<your-project-id> as scratch gets purged every 60 days

 

Below is the output of your SLURM output file:

Copy the following two lines in a new terminal one after another to create\na secure SSH tunnel between your computer and Shaheen compute node. ssh -L 10121:localhost:10121 shaima0d@cdl2.hpc.kaust.edu.sa ssh -L 10121:nid00233:10121 shaima0d@gateway2 Trace: [2022-12-13T13:59:03.113Z] trace child:32698 got message {"message":{"type":"handshake","args":{"bind-addr":"nid00233:10121","auth":"password","password":"10DowningStreet","config":"/scratch/shaima0d/tickets/45007/config","user-data-dir":"/scratch/shaima0d/tickets/45007/data","verbose":true,"extensions-dir":"/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/extensions","log":"trace","host":"nid00233","port":10121,"proxy-domain":[],"_":[],"usingEnvPassword":false,"usingEnvHashedPassword":false}}} at doLog (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:57:28) at ServerFormatter.doWrite (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:204:9) at ServerFormatter.write (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:119:14) at Logger.handle (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:339:25) at Logger.trace (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:268:14) at process.onMessage (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/out/node/wrapper.js:72:47) at process.emit (node:events:513:28) at emit (node:internal/child_process:939:14) at processTicksAndRejections (node:internal/process/task_queues:84:21) Trace: [2022-12-13T13:59:03.116Z] trace Using extensions-dir /lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/extensions at doLog (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:57:28) at ServerFormatter.doWrite (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:200:20) at ServerFormatter.write (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:119:14) at Logger.handle (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:339:25) at Logger.trace (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/node_modules/@coder/logger/out/logger.js:268:14) at /lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/out/node/main.js:122:21 at Generator.next (<anonymous>) at /lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/out/node/main.js:31:71 at new Promise (<anonymous>) at __awaiter (/lustre/scratch/shaima0d/tickets/45007/codeserver/share/code-server/out/node/main.js:27:12) [2022-12-13T13:59:03.116Z] info code-server 4.9.0 0502dfa1ff42ab8a43adb911f7bf21f8b09ee25f [2022-12-13T13:59:03.116Z] info Using user-data-dir /scratch/shaima0d/tickets/45007/data [2022-12-13T13:59:03.161Z] info Using config file /scratch/shaima0d/tickets/45007/config [2022-12-13T13:59:03.161Z] info HTTP server listening on http://10.128.0.234:10121/ [2022-12-13T13:59:03.161Z] info - Authentication is enabled [2022-12-13T13:59:03.161Z] info - Using password from /scratch/shaima0d/tickets/45007/config [2022-12-13T13:59:03.161Z] info - Not serving HTTPS

Step 3

Port forwarding is required to bind to the listening port of the remote host (Shaheen compute node). For this, open a new terminal window and start an SSH tunnel to achieve the above:

and then:

Step 4

Once the SSH tunnel is established, paste the following URL in your browser’s address bar and you can access code-server's User Interface. You will need to use the password you have set in your jobscript (or can find it in your config file)

When finished, please don’t forget to scancel the job on Shaheen.