Global Static Files

Directory Structure

|-- global_static_files/
  |-- global_static_files.yaml
  |-- files/
    |-- hello/
    |-- world/
    |-- test.html
    |-- ...

The global_static_files.yaml file contains configuration information for global static files and directories, while the actual file contents are stored in the files/ directory.

Configuration Description

Each static file or directory configuration is an object containing the following parameters:

Parameter NameData TypeRequiredDescription
typestringYesType, can be “file” or “dir”
pathstringYesPath of the file or directory
namestringYesName of the file or directory
labelstringNoLabel for the file or directory

Configuration Example

- type: dir
  path: dir1
  name: dir1
- type: dir
  path: dir2
  name: dir2
- type: dir
  path: dir1/dir12
  name: dir12
- type: file
  path: hello.html
  name: hello.html
- type: file
  path: dir1/setup.sh
  name: setup.sh
- type: file
  path: dir1/hello.html
  name: hello.html
- type: file
  path: dir1/stream.pcap
  name: stream.pcap

This configuration defines multiple directories and files. The directory structure is as follows:

/
├── dir1/
│   ├── dir12/
│   ├── setup.sh
│   ├── hello.html
│   └── stream.pcap
├── dir2/
└── hello.html

Usage Example

Update configuration to OpenResty Edge:

edge-config https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -l global_static_files -i /root/oredge-configs

Export configuration from OpenResty Edge:

edge-config -u https://192.168.1.1 -s -t 2051e780-1897-4ea0-92b4-2c2f0169aa94 -E -l global_static_files

Both examples use -l global_static_files to specify importing/exporting only global static file-related configurations.

Notes

  1. Global static files are a global configuration. Delete operations are not performed when updating configurations to maintain compatibility with multiple local configurations.

  2. The actual content of files is stored in the global_static_files/files/ directory, and the directory structure should be consistent with the path in the configuration.

  3. When importing configurations, the tool first checks the validity of the configuration before performing add or update operations.

  4. For file types, the tool calculates the MD5 value of the local file and compares it with the file on the server. The file is only updated when the content has changed.

  5. For directory types, if the directory does not exist, the tool will create the corresponding directory.

  6. When exporting configurations, the tool will download the file contents from the server to the local global_static_files/files/ directory.

  7. The configuration file (global_static_files.yaml) and the actual file contents are stored and managed separately, allowing for more flexible version control and file management.

  8. only files and directories listed in global_static_files.yaml will be processed when updating configurations. Files on the server that are not listed in the configuration will not be automatically deleted.