Complete code examples demonstrating all operations are available on Blaxelโs GitHub: in TypeScript and in Python.
Execute processes and commands
Set up authentication to Blaxel
Set up authentication to Blaxel
The Blaxel SDK authenticates with your workspace using credentials from these sources, in priority order:
- when running on Blaxel, authentication is handled automatically
- variables in your
.envfile (BL_WORKSPACEandBL_API_KEY, or see this page for other authentication options). - environment variables from your machine
- configuration file created locally when you log in through Blaxel CLI (or deploy on Blaxel)
Execute command
Execute shell commands using the TypeScript SDK:waitForCompletion: true / "wait_for_completion": True parameter.
Use process names
When starting a process (running a command), you can specify a process name. This lets you interact with the processโsuch as retrieving logs or process informationโwithout needing to store the process ID on your end.Wait for process completion
You can wait for process completion when executing it:.logs object which surfaces both stdout and stderr. Also, notice the timeout parameter which allows to set a timeout duration on the process.
When using
waitForCompletion, Blaxel enforces a timeout limit of 100 seconds. Donโt set your timeout longer than this. For longer waiting periods, use the process-watching option described below.Wait for ports
In some cases, you may want to wait for a port to be opened while running โ for example if you are runningnpm run dev and want to wait for port 3000 to be open.
Kill process
Kill a process immediately by running:Process statuses
A process can have either of the following status:runningcompletedfailedkilledstopped
