Skip to main content

s6 manages processes in a workstation

Our workstations provide users multiple processes, such as JupyterLab, and RStudio Server, and VS Code Server. To run these processes concurrently, our workstations use s6, a tool for multi-process supervision and management. Our workstations use s6 because s6 is ideally suited for containers. S6 provides similar process management functionality for containers as tools such as systemd provide for physical and virtual Ubuntu machines. s6 knows what processes should run at the start of a workstation, which services should stay active for the life of the workstation, and how to restart processes if they go down. Users can also use s6 to run custom applications such as Streamlit applications.

Listing, stopping, and starting s6 services

s6-rc provides functions for listing, stopping, and starting s6 services. In these examples, we list all services, identify the service for VS Code server, stop the server, and restart it. These commands should be run from a different endpoint from VS Code server, such as JupyterLab or SSH.

List all s6 services
s6-rc -a list

Services whose names begin application--user--bench-user-- can be modified by users. For example, the s6 service for VS Code server is named application--user--bench-user--code-server--server.

We do not recommend changing services that begin with system-- or application--system--, as this could cause the workstation to become unresponsive.

caution

Stopping a s6 service while connected to that service will immediately disconnect you. If no other endpoints are running, the entire workstation may have to be restarted to regain access. If restarting is necessary, you will lose any unsaved work.

Modifying s6 services

Sometimes, a user may wish to modify the way a service is running, such as changing the conda environment used with RStudio Server. The example below shows a general pattern for performing this task.

s6 services that users have the ability to modify have names that begin with application--user--bench-user--. The service definition files for these applications are located at /home/bench-user/.s6-overlay/s6-rc.d/{application-name}/run.

Changing the conda environment for RStudio

While RStudio Server does not explicitly support using multiple conda environments, s6 can change the RStudio Server configuration and then restart the service. This pattern is useful for changing the version of R, or using a conda environment that contains incompatible packages. In this example, we create a new conda environment with R version 4.0, then modify the RStudio Server s6 script to run in this conda environment.

Changing the conda environment used with RStudio Server
# Visiting RStudio Server in the browser will typically use the base conda environment and a recent version of R.
# First, create a conda environment with the older version of R.
mamba create --yes --name r-4.0 --channel conda-forge r==4.0


# Backup the s6 script that controls the RStudio service.
cp /home/bench-user/.s6-overlay/s6-rc.d/application--user--bench-user--rstudio-server--server/run \
/home/bench-user/.s6-overlay/s6-rc.d/application--user--bench-user--rstudio-server--server/run_backup

# Change the script to activate the "r-4.0" conda environment before starting the service.
sed -i "s/R_CONDA_ENV=base/R_CONDA_ENV=r-4.0/g" \
/home/bench-user/.s6-overlay/s6-rc.d/application--user--bench-user--rstudio-server--server/run

# Copy the s6 script from the home directory in to the s6 service directory in /var
sudo cp /home/bench-user/.s6-overlay/s6-rc.d/application--user--bench-user--rstudio-server--server/run \
/var/run/s6-rc/servicedirs/application--user--bench-user--rstudio-server--server/run

# Stop and restart the service
sudo s6-rc stop application--user--bench-user--rstudio-server--server \
&& sudo s6-rc start application--user--bench-user--rstudio-server--server

After running the commands above, refresh your connection to RStudio Server to use the new conda environment. You can verify the version of R that is running by typing the command sessionInfo() in R.

The s6 service directories in /var/run are refreshed from the persistent home directory during the start of a workstation. Therefore, RStudio Server will use this conda environment until a new environment is specified or the change is removed.

Logs for RStudio Server are in /home/bench-user/.log/rstudio-server/server. If you misconfigure the server, simply restore the run file from run_backup, copy run to the location in /var, and stop/start the service again.

Need help?

For assistance customizing applications, contact customer support.

Adding new s6 services

Need help?

For assistance running custom applications, contact customer support.