Skip to main content

Advanced Guide

Folder Structure and Descriptions

After installing the scripts, you should have a folder structure like this:

startup.sh                # Updating and running the application
scripts/ # Main directory for the Node.js CLI application
│ ├── helpers/
│ │ ├── helpers.js
│ │ └── setup_environment.js
│ ├── media/
│ ├── node_modules/
│ ├── staticfiles/
│ └── volume_backup/ # if you have performed a backup
│ ├── .env.prod
│ ├── docker-compose.yml # Entry point for initiating the Docker environment
│ ├── index.js # Entry point for the Node.js CLI application
│ ├── package-lock.json
│ ├── package.json
│ ├── variables.json

helpers/

Stores essential functions required for the scripts to execute. These functions are used across various parts of the application to ensure consistency and reusability.

media/

Holds user-uploaded files within the Docker volume. This directory is mounted to persist data even when containers are restarted or recreated.

node_modules/

Contains necessary Node.js modules for the CLI application. This directory is generated by npm or yarn based on the dependencies listed in package.json.

staticfiles/

Houses frontend assets for the tool within the Docker volume. These assets include images, CSS files, and JavaScript files used by the web interface.

volume_backup/

Stores any backups that have been made. This can include database dumps, configuration files, or other critical data needed for disaster recovery.

.env.prod

Holds environment variables for the backend. This file is crucial for configuring the application's behavior in a production environment, including database connections, API keys, and other sensitive information.

docker-compose.yml

The primary entry point for initiating the Docker environment. This file defines the services, networks, and volumes used in the multi-container Docker application, enabling seamless orchestration and management.

index.js

Entry point for the Node.js CLI application. This script initiates the application's main processes and handles command-line arguments and execution flow.

package-lock.json / package.json

Lists external libraries required for the script. The package.json file specifies the project's dependencies, scripts, and metadata, while package-lock.json ensures consistent installations across different environments by locking dependency versions.

variables.json

Stores variables from the last script checkpoint, including CPU architecture, API URL, and weekend day. This file allows the application to resume operations or maintain state based on previously recorded data.

Running the Application

Using the Startup Script

The startup.sh script is designed to ensure your application is up to date before running. It performs the following tasks:

  1. Self-Update: The script updates itself from our servers to ensure you're using the latest version.
  2. Pull Updates: It pulls the latest changes for the scripts folder from our repository.
  3. Run the Application: Finally, it executes the index.js Node.js application using the command node index.js.

To run the startup script, simply execute:

./startup.sh

Directly Running the Node.js Application

If you prefer not to update and just want to get the tool up and running quickly, you can directly run the index.js file. This bypasses the update process.

To run the Node.js application directly, use:

node index.js

Running with Docker Compose

For a more advanced setup, you can use Docker Compose to run the application. This method ensures that all dependencies and configurations are handled within a Docker container, providing a consistent environment.

To run the application using Docker Compose, navigate to the directory containing the docker-compose.yml file and execute:

docker-compose up

If you prefer to run the Docker container in the background, freeing up your terminal, you can add the -d flag:

docker-compose up -d

This command will start the services defined in the docker-compose.yml file inside the scripts directory, allowing the application to run asynchronously.

Summary

  • startup.sh: Ensures the application is up to date and then runs it.
  • Direct Execution: Runs the application without updating, using node index.js.
  • Docker Compose: Provides an advanced, containerized way to run the application, with optional asynchronous execution using the d flag.