How to use code-server on the cluster¶
Code-server is a version of VSCode designed to run in your web browser like the one available on the institutional forge. Here we will run code-server on a compute node and access it by using an SSH tunnel.
This tutorial is based on cluster How-to documentation.
Configure (once)¶
Connect to the cluster, and run code-server to create config files in ~/.config/code-server. During this step, you need to hit Ctrl+C to stop code-server when it display Session server listening on ...
[...] info code-server 4.96.4 b7ef8f9bd70cb5b342fa8ec8a0086bad676d8124
[...] info Using user-data-dir /home/<user>/.local/share/code-server
[...] info Using config file /home/<user>/.config/code-server/config.yaml
[...] info HTTP server listening on http://127.0.0.1:8080/
[...] info - Authentication is enabled
[...] info - Using password from /home/<user>/.config/code-server/config.yaml
[...] info - Not serving HTTPS
[...] info Session server listening on /home/<user>/.local/share/code-server/code-server-ipc.sock
^C
Then edit the file ~/.config/code-server/config.yaml:
| ~/.config/code-server/config.yaml | |
|---|---|
1 2 3 4 5 6 | |
- By setting 0.0.0.0 instead of 127.0.0.1, you can connect to code-server from another machine. We recommend to change the default port 8080 by another one between 1024 and 65535. You will avoid collision with other user this way. Here we set it to 8888.
- You can change the password. Replace the
<random password>by what you want. - Disable telemetry (optional)
- Set your interface language (optional)
Use code-server¶
There is two main steps:
- Run
code-serveron a compute node, - Connect to it with your web browser by using a ssh tunnel.
Run code-server¶
# Alternatively, you can change some parameters (`code-server -h`)# Here we run code-server on port 8989 without password protection code-server --bind-addr 0.0.0.0:8989 --auth none ...
You can get code-server options by looking at code-server documentation or by using its help command code-server -h
Connect to code-server¶
In order to connect to code-server, we need to create a ssh tunnel like in OOD tutorial.
From previous step, we know that code-server runs on node n001 and listen on port 8989.
We open a new terminal on our computer and start a second ssh connection following the command template ssh -N -L <local-port>:<nodename>:<remote-port> <my-login>@genobioinfo.toulouse.inrae.fr:
You can stop it by hitting the Ctrl+C combination. If you stop it by mistake, run the command again.
Now open your browser and go to url http://127.0.0.1:<local-port>. In our example it is http://127.0.0.1:8080.
Enter the password set in the config.yaml or set in your code-server command.
Stop everything¶
- In the terminal where the
code-serveris running, hit Ctrl+C and then stop your interactive job (srun) withexitcommand or Ctrl+D. - In the terminal where you create the tunnel, hit Ctrl+C .