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.

Note: Catalyst restricts file write permissions in the current directory during an AppSail service's execution. If you require to create or write a file in the current directory during the app's execution, you must instead write it in a temporary directory of your operating system.

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.

Note: When you initialize a Java app as a WAR file, you need not provide any embedded server for your app, as Catalyst bundles it with the Jetty server by default. You therefore need not provide any startup commands either. Catalyst will handle the application startup. However, you will need to embed a server if you select the Java SE option and provide startup commands accordingly. You can go through the Java Help Guide for some examples.

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.

Note: You will not be able to modify the port that Catalyst assigns for network access.

Certain frameworks expect the HTTP listen port to be specified in the command line while starting the server.

For example:

    
copy
python3 -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:

    
copy
sh -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.

Note: If you want to declare a production variable, you must have deployed your project to the Production environment. You will not be able to access production variables if your project is not deployed, or if the production environment is disabled.

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:
    
copy
System.getenv(variable_name)
  • Node.js:
    
copy
process.env.[variable_name]
  • Python:
    
copy
os.getenv(variable_name)

variable_name: The keyname declared for the variable

Note: The variable's value is fetched based on the environment the app is invoked in. That is, if the [development URL](#custom-domain-url) of the app is invoked, the development value of the variable is fetched. If the production URL is invoked, the production value is fetched.

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.

Note: The CPU is allocated automatically based on the memory you configure for your function. You won't be able to view or configure this 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:

    
copy
https://appsailservicename-ZAID.development.catalystappsail.com

For example:

    
copy
https://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.

Note: The "development" indicates the development environment of your project. After you deploy your project to production, the URL will not include that key.

Last Updated 2024-02-23 17:29:25 +0530 +0530