Catalyst Serve Options
Catalyst CLI enables a variety of options that you can use with the catalyst serve command.
You can serve the resources locally in any port you require, other than the default port 3000. You can do this by using the --http option and including the port number where you need the resources to be served from.
For example, to serve your resources from port 2000, execute the following command from your project directory:
Catalyst enables you to start the local server in the debug mode and attach a debugger to the live server. You can debug the code of your Basic I/O and Advanced I/O functions of your project. You can associate the server to a debugger instance of your IDE that you use to develop the code with. This allows you to debug the execution of your functions, and identify the errors and issues in the code.
You can also choose to start the server at a port of your choice similar to the –http<port> option. The default port where Basic I/O functions are attached to the debugger is 8010 and Advanced I/O functions is 8000.
You can start the local server in the debug mode by executing the following command from the project directory:
You have to specify the name of the Advanced I/O functions while using this option. You need not specify the names of the Basic I/O functions For example:
This will start the local server at the default port 3000. The resources will be served and the local endpoints will be displayed. You can then attach the debugger at port 2000 for the Advanced I/O function, and port 4000 for the Basic I/O functions. The server will be listening at these ports for the debugger.
After you see this message, open your IDE and attach the debugger to the ports you specified for the functions. The CLI will display a confirmation message after it is attached. You can now test your resources and debug them. The CLI will display the errors caught by the debugger, along with their details.
Catalyst enables you to proxy an unknown request to the localhost URL generated by the server in the CLI. This allows you to proxy the requests that are encountered during the serve of functions. Such requests will be proxied to the Catalyst console by default.
You can specify the URL to proxy the unknown requests to, while executing the serve command as follows:
You can serve specific targets instead of all the resources using this option. For example, you can serve specific functions, or the client package alone.
To serve specific targets, execute the catalyst serve command with the --only option followed by the targets to be served as shown below:
Catalyst CLI provides a live watch mode by default, which allows you to perform hot reload of the resources that are being served. This enables you to view the updates of the changes you make instantly, without having to re-compile or re-serve the code.
However, if you require the live watch mode to be disabled, you can do so using this option. You can use this option if you don’t have to make changes in the code, such as while serving a production-ready build, or if don’t require the updates to be reflected live.
You can serve resources with the default live watch disabled as shown below:
This will make the server compile the code only when the code is served initially. The server will not watch for changes after the code is served. The updates will not be reflected live when you test the resources.
If you require the default live watch mode to be enabled again, you must exit the serve session, and re-serve the code without using this option.
You can choose to exclude specific resources from being served using this option. For example, you can exclude specific functions or the client package.
To exclude a specific function, execute the catalyst serve command with the –except option followed by the target name as shown below:
Catalyst enables you to automate the CLI and terminal command executions by defining scripts in the catalyst.json file in your project directory. You can define two lifecycle scripts to execute before and after the catalyst serve command respectively: preserve, postserve . You can learn more about the lifecycle and custom scripts from the Scripts help page .
If you use the –ignore-scripts option while executing the catalyst serve command, the CLI will ignore the actions configured for the preserve and postserve scripts in the catalyst.json file of your project directory. The deployment process will proceed without the execution of these lifecycle scripts.
You can use the –ignore-scripts option as follows:
The serving process will be the same as discussed earlier.
When you execute the serve command and the server hosts the code, the CLI will redirect you to your default browser automatically to open the client component in your project. If you require this automatic redirection to be disabled, you can execute the serve command with this option as shown below:
The CLI will display the localhost URL of all the served components as usual. You can still open the web client manually by accessing the URL, if you require.
You can use this option when you don’t require the client component to be tested, or while performing a test run of a production-ready build.
Last Updated 2023-05-09 17:07:05 +0530 +0530
Send your feedback to us