Start Server
The blocklet server start
command initializes and runs the Blocklet Server as a background daemon process. It reads the configuration from the current directory, performs necessary checks and migrations, and then launches the server.
Usage#
To start the server, navigate to your Blocklet Server's data directory and run:
blocklet server start
Startup Process Flow#
The startup command orchestrates a series of critical steps to ensure the server starts correctly and in a consistent state. This includes version checks, data migrations, and service initializations.
Command Options#
Several flags can be used to modify the startup behavior.
Option | Alias | Description |
---|---|---|
|
| Updates the Blocklet Server database with the latest settings from the configuration file. This is useful when you've manually edited your |
|
| If the server configuration and data directory do not exist in the current path, this flag will automatically initialize them before starting the server. |
|
| Forces the server to start in a specific mode, such as |
| Forces the server to run in intranet mode, ignoring any external IP addresses. This is useful for local development or isolated network environments. |
Key Operations During Startup#
When you run blocklet server start
, several important tasks are performed automatically:
- Version Compatibility Check: The command first checks if the installed CLI version is compatible with the version of the Blocklet Server instance specified in the configuration. If there's a major version mismatch, it will prevent the server from starting to avoid potential issues. You can bypass this check by setting the
ABT_NODE_SKIP_VERSION_CHECK
environment variable totrue
. - Database & Data Migrations: The server automatically runs any necessary migrations to update the database schema and application data. This ensures that your server is always running on the latest data structures, even after an upgrade.
- Configuration Synchronization: If you provide the
--update-db
flag, the command compares yourconfig.yml
file with the configuration stored in the database. If differences are found, it will update the database to match your file. - Process Management: The command uses
pm2
to manage the core background processes, including the maindaemon
and theservice
process. This ensures the server runs reliably and can be managed easily. - Crash Recovery: If the server was not shut down cleanly (e.g., due to a crash), the startup process will attempt to recover. It can create a notification in the dashboard and will restart any blocklets that were running before the crash.
- Dependency Checks: The server ensures that essential services like Redis and PostgreSQL are available and running before proceeding with the startup.
Examples#
Basic Start#
This command starts the Blocklet Server located in the current directory.
blocklet server start
Start with Auto-Initialization#
If you're in a new directory, this command will first initialize a new Blocklet Server configuration and then start it.
blocklet server start --auto-init
Applying Configuration Changes#
After modifying config.yml
(for example, to change the server's port or routing), use --update-db
to apply these changes on startup.
# Suppose you changed the port in your config file
blocklet server start --update-db
Once the server is running, you can check its status using blocklet server status
.
Next, learn how to Stop the Server.