Launching Services and Background Processes¶
When building assignments, you may need additional tools or services such as databases, frameworks, or background processes.
Lab.Computer allows you to automate their installation and startup using an initialization script named init.sh.
Enabling the init.sh Script¶
Create an init.sh script in the root directory of your notebook environment. This script executes each time the project is launched, allowing you to install and start any required services.
Example: Installing and Starting MySQL¶
#!/bin/bash
sudo apt-get update
sudo apt-get install -y mysql-server
sudo systemctl start mysql
When the project launches, this script installs MySQL and starts the database service.
Note
After adding or modifying the init.sh script, you must stop, save, and restart the course for the changes to take effect.
Setting script permissions¶
Before the script can run, you must set the proper permissions.
Open a terminal in your notebook:
- From the notebook home page, select Terminal under the Other section, or
- Go to File → New → Terminal.
Then run:
chmod 755 init.sh
This grants execute permissions to the script.
Debugging init.sh execution¶
Each time the script runs, a log file is generated in your notebook’s home directory. The log file name follows the format:
init_logs_TIMESTAMP.log
Open this log to inspect the output and debug any issues that occur during script execution.