Differences between revisions 2 and 3
Revision 2 as of 2022-06-09 15:40:15
Size: 2601
Editor: stroth
Comment:
Revision 3 as of 2022-06-13 14:02:29
Size: 1778
Editor: stroth
Comment: Remove unused example; Add info about application data path
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
== Example: Start openvscode-server in an interactive Slurm job == == Use case: Start openvscode-server in an interactive Slurm job ==
Line 22: Line 22:
== Example: Slurm job with openvscode-server ==
Adjust the following script snippet to your needs and insert it into your [[Services/SLURM#sbatch_.2BIZI_Submitting_a_job|sbatch]] script:
{{{#!highlight bash numbers=disable
# Set a logfile path in a variable
OVS_LOG=$HOME/openvscode-server.log
== VSCode data ==
''OpenVSCode Server'' stores it's data in `$HOME/.openvscode-server`, separated from the'' VSCode desktop application'' which stores it's data in `$HOME/.vscode`. Both store their extensions in the subdirectory `extensions`.
Line 28: Line 25:
# Store the hostname in a variable
OVS_HOST=$(hostname -f)

# Define the command to start openvscode-server
OVS_COMMAND="openvscode-server --host ${OVS_HOST} --accept-server-license-terms --telemetry-level off |sed 's/localhost/$OVS_HOST/g'"

# Start a job step with openvscode-server with its own cpu core and put it into the background
srun --exclusive --ntasks=1 --cpus-per-task=1 "$OVS_COMMAND" >"$OVS_LOG" &

# Run some more code
python ...
}}}

`OVS_LOG` will contain the URL to access the web-based Code editor:
{{{
Server bound to <public ip of OVS_HOST>:<random port> (IPv4)
Extension host agent listening on <random port>

Web UI available at http://<OVS_HOST>:<random port>/?tkn=01234567-89ab-cdef-0123-456789abcdef
}}}

== The token ==

Run Visual Studio Code as a service on a remote host

Two SEPP software packages of Visual Studio Code are available:

  • Code, started from the command line with code, the desktop application

  • OpenVSCode Server, started from the command line with openvscode-server, the web application

This article explains how to start openvscode-server as a service on a remote PC or cluster node and connect to it with a web browser.
A typical use case is to start it within a cluster job for debugging.

Use case: Start openvscode-server in an interactive Slurm job

Within an interactive shell in a Slurm job, issue the following command:

OVS_HOST=$(hostname -f) && openvscode-server --host $OVS_HOST --accept-server-license-terms --telemetry-level off |sed "s/localhost/$OVS_HOST/g"

The output of openvscode-server will tell you the URL to access the web-based Code editor:

Server bound to <public ip of OVS_HOST>:<random port> (IPv4)
Extension host agent listening on <random port>

Web UI available at http://<OVS_HOST>:<random port>/?tkn=01234567-89ab-cdef-0123-456789abcdef

VSCode data

OpenVSCode Server stores it's data in $HOME/.openvscode-server, separated from the VSCode desktop application which stores it's data in $HOME/.vscode. Both store their extensions in the subdirectory extensions.

The example token 01234567-89ab-cdef-0123-456789abcdef is saved in $HOME/.openvscode-server/data/token and will be re-used at future starts of openvscode-server.

FAQ/VS-Code_Server (last edited 2022-06-21 08:42:05 by stroth)