docs: Update 2 files
This commit is contained in:
39
TEMPLATES.md
39
TEMPLATES.md
@@ -11,6 +11,7 @@ template-name/
|
||||
├── template_info.env # REQUIRED: Template metadata (at root level)
|
||||
├── config/
|
||||
│ └── service.env # REQUIRED: Default service configuration
|
||||
├── install-pre.sh # OPTIONAL: Pre-install script (runs BEFORE uninstall, e.g. docker pull)
|
||||
├── install.sh # REQUIRED: Installation script
|
||||
├── uninstall.sh # REQUIRED: Uninstallation script
|
||||
├── status.sh # REQUIRED: Check service status (needed for 'dropshell list' command)
|
||||
@@ -152,7 +153,41 @@ This means:
|
||||
- Variables in `service.env` override those in `template_info.env` if they have the same name
|
||||
- Users customize deployments by editing `service.env`, never `template_info.env`
|
||||
|
||||
### 3. install.sh
|
||||
### 3. install-pre.sh (OPTIONAL)
|
||||
|
||||
Pre-install script that runs **before the old service is uninstalled**. This is useful for reducing downtime by performing slow operations (like pulling Docker images) while the old service is still running.
|
||||
|
||||
**When does it run?**
|
||||
- Only when updating an existing service (not on first install)
|
||||
- Checked in the local template cache first (fast, no remote calls)
|
||||
- Only synced and run on the remote server if the script exists in the template
|
||||
|
||||
**If install-pre.sh fails**, installation continues with a warning. It is not considered a fatal error.
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
# Pull the new Docker image while the old service is still running
|
||||
docker pull -q "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Warning: pre-pull failed, install.sh will retry"
|
||||
|
||||
echo "Pre-install complete"
|
||||
```
|
||||
|
||||
**Docker Compose example:**
|
||||
```bash
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# Pull updated images while the old service is still running
|
||||
docker compose -p "${CONTAINER_NAME}" pull || echo "Warning: pre-pull failed, install.sh will retry"
|
||||
|
||||
echo "Pre-install complete"
|
||||
```
|
||||
|
||||
### 4. install.sh
|
||||
|
||||
Installation script that sets up the service:
|
||||
|
||||
@@ -182,7 +217,7 @@ bash ./start.sh || _die "Failed to start container"
|
||||
echo "Installation of ${CONTAINER_NAME} complete"
|
||||
```
|
||||
|
||||
### 4. uninstall.sh
|
||||
### 5. uninstall.sh
|
||||
|
||||
Uninstallation script to remove the service (must be non-interactive and MUST preserve data):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user