Entrypoints

This document outlines the entrypoints for the Daytona application.

cmd/daytona/main.go

This is the main entrypoint of the Daytona application. The main function initializes the application and starts the server. The init function is used for initialization tasks such as setting up logging and loading configuration files.

main function:

The main function is responsible for initializing the application and starting the server. It performs the following tasks:

  1. Initialize logging: The init function sets up logging based on the configuration file.
  2. Load configuration: The configuration file is loaded and parsed.
  3. Initialize server: The server is initialized with the loaded configuration.
  4. Start server: The server is started and listens for incoming requests.

Example:

package main
          
          import (
              "log"
          
              "github.com/your-organization/daytona/config"
              "github.com/your-organization/daytona/server"
          )
          
          func init() {
              // Initialize logging
              if err := config.InitLogger(); err != nil {
                  log.Fatalf("failed to initialize logger: %v", err)
              }
          }
          
          func main() {
              // Load configuration
              cfg, err := config.LoadConfig()
              if err != nil {
                  log.Fatalf("failed to load configuration: %v", err)
              }
          
              // Initialize server
              srv := server.NewServer(cfg)
          
              // Start server
              if err := srv.Start(); err != nil {
                  log.Fatalf("failed to start server: %v", err)
              }
          }
          

init function:

The init function is called before the main function. It is used for initialization tasks that need to be performed before the application starts.

Example:

package main
          
          import (
              "log"
          
              "github.com/your-organization/daytona/config"
          )
          
          func init() {
              // Initialize logging
              if err := config.InitLogger(); err != nil {
                  log.Fatalf("failed to initialize logger: %v", err)
              }
          }