AppSail Execution
Common Build Files
Based on the programming stack and framework, your compiled or deployable code could be of any format in any structure. Some common formats are mentioned below:
- Java:
As mentioned earlier, AppSail enables you to initialize or add a Java AppSail service from the CLI in one of the two formats: Java SE and Java WAR.
Java WAR indicates that the final build file is of a .war format. A WAR file is essentially a standard deployable format that can be readily run on any application server. It is a container for JAR files, JavaServer Pages, Java Servlets, Java classes, XML files, HTML, CSS etc of the application’s source.
If your build files are of any other format besides a .war file, you can select the Java SE template. Some other formats include .jar or compiled class files, .class. If you use any Java frameworks or libraries, you must include those files in the build path.
- Node.js:
The deployable main file is typically a .js file. Based on the standards of the framework or the dependencies you add, there will be node modules and configuration files included in your app’s directory. You must ensure that you add all node modules and configuration files, along with the main file and native client files in the build path.
- Python:
The deployable main file is typically a .py file. Based on the standards of the framework, plugins, or dependencies you add, there will be Python and configuration files included in your app’s directory. You must ensure that you add all modules and configuration files, along with the main file and native client files in the build path.
You can refer to the Help Guide on building sample apps to learn more about using popular frameworks in each stack and deploying them as AppSail services.
Startup Commands
You can configure startup commands for your AppSail services that specify starting up the app based on the programming stack, framework, application files, and the web server used. Essentially, this is the command that you would provide in your local environment to start up an application with your configured server.
The startup command can be configured for an app in two ways:
-
In theapp-config.json file for the key command. You can edit this file and then serve it or deploy it to the remote project.
-
Directly in the console. You can find the steps for this here.
Java:
Java applications typically include embedded servers in the app’s code, based on the framework used. For example, Spring Boot apps come bundled with web servers by default. However, certain frameworks or formats might not include servers by default, and you will need to configure an embedded server independently in your Java code. Some common web servers that are used are Eclipse Jetty or Apache Tomcat.
Node.js and Python:
For Node.js and Python applications, depending on the frameworks you use, deployment servers might be included as a part of the framework. You will need to configure and manage application servers accordingly, and provide appropriate startup commands for your apps. Catalyst does not provide any built-in support for any servers for these programming environments.
Default Port for App Startups
AppSail listens through HTTP ports for network access in your application. That is, the entire traffic to the app will be listened through a specific port. You can listen to the AppSail port provided by Catalyst by referring to the environmental variable key X_ZOHO_CATALYST_LISTEN_PORT in your application code to connect to the Internet. Catalyst will check for the process listening on this port.
Refer to the Help Guide section for examples of configuring the AppSail listen port in your application’s code.
Certain frameworks expect the HTTP listen port to be specified in the command line while starting the server.
For example:
copypython3 -m http.server ${X_ZOHO_CATALYST_LISTEN_PORT}
However, in AppSail, the startup commands are executed directly without any involving any shell operations. Therefore, when needed, you must specify the startup command to be executed as a shell command for any shell completions.
For example:
copysh -c 'python3 -m http.server ${X_ZOHO_CATALYST_LISTEN_PORT}'
Environmental Variables
Environmental variables are variables whose values are declared outside of the main source code. After an environmental variable is created, it can be called in any of the functions or classes in the application’s directory.
Catalyst enables you to create, store, and manage variables for both the development and production environments. You can declare a single variable and configure values for both these environments. For example, if you need to declare an auth token variable that will hold different values in both environments, you can do so.
AppSail allows you to configure environmental variables in two ways:
-
In the app-config.json file for the key env_variables. Refer the sample code of app-config.json shown earlier for the syntax of declaring the keyname and values in development and production. You can edit this file and then deploy it to the remote project.
-
Directly in the console. You can find the steps for this here.
Use an Environmental Variable
After you create an environmental variable, you can call it in your app’s code by its keyname in different ways in different programming environments. The syntax for each programming environment is given below:
- Java:
copySystem.getenv(variable_name)
- Node.js:
copyprocess.env.[variable_name]
- Python:
copyos.getenv(variable_name)
variable_name: The keyname declared for the variable
Memory Allocation
You can allocate memory for your app’s execution based on its load and performance requirements. If you do not specifically configure a memory for your app, the default memory of 256 MB will be allocated for its execution.
You can always edit the default or previously configured memory after analysing its requirements, and optimize its performance and cost by selecting an optimal value.
AppSail allows you to configure the memory in two ways:
-
In the app-config.json file for the key memory. You can edit this file and then deploy it to the remote project.
-
Directly in the console. You can find the steps for this here.
Custom Domain URL
After your AppSail service is deployed to the remote project, Catalyst host your app on a custom domain through which you can access it. You can access the various endpoints that you configure in your app following this base URL.
The base URL of the custom domain is of the format:
copyhttps://appsailservicename-ZAID.development.catalystappsail.com
For example:
copyhttps://demoservice-1011034735.development.catalystappsail.com
-
AppSail service name: The name you provide while initializing the app in the CLI
-
ZAID: The unique identifier that maps an application to a project. The ZAID is different in the development and production environments of a project.
Last Updated 2024-02-23 17:29:25 +0530 +0530
Yes
No
Send your feedback to us