Skip to content

Instantly share code, notes, and snippets.

@bueller
Created January 8, 2016 00:17
Show Gist options
  • Save bueller/a71cf29a43b36b3608c6 to your computer and use it in GitHub Desktop.
Save bueller/a71cf29a43b36b3608c6 to your computer and use it in GitHub Desktop.
# My Counter App version 1.0 with zero downtime redis backup
---
replicated_api_version: 1.3.0
name: My Counter App
version: "1.0"
release_notes: The initial release of my counter application.
properties:
app_url: http://{{repl ConfigOption "hostname" }}
logo_url: ""
console_title: My Counter App Console
admin_commands:
- alias: backup-redis-to-rdb
command:
- redis-cli
- bgsave
run_type: exec
component: DB
image:
image_name: redis
version: latest
- alias: mv-backup-rdb-to-safe-place
command:
- mv
- /data/dump.rdb #default path of redis backup that we want to move offsite
- "{{repl ConfigOption \"backup_path\"}}/dump.rdb" #path set in config screen
run_type: exec
component: DB
image:
image_name: redis
version: latest
backup:
enabled: true
pause_all: false
script: |
#!/bin/bash
sudo replicated admin --no-tty backup-redis-to-rdb
sudo replicated admin --no-tty mv-backup-rdb-to-safe-place
state:
ready:
command: http_status_code
args:
- http://{{repl ConfigOption "hostname"}}/assets/bootstrap.min.css
- "200"
cmds:
- name: host_ip
cmd: publicip
args: []
monitors:
memory:
- LB,nginx
components:
- name: DB
containers:
- source: public
image_name: redis
version: latest
cmd: "[\"redis-server\", \"--appendonly\", \"yes\"]"
publish_events:
- name: Container redis started
trigger: container-start
data: ""
subscriptions:
- component: App
container: freighter/counter
action: start
config_files: []
customer_files: []
env_vars: []
ports: []
volumes:
- host_path: /data
container_path: /data:rw
is_excluded_from_backup: true
- host_path: "{{repl ConfigOption \"backup_path\"}}"
container_path: "{{repl ConfigOption \"backup_path\"}}"
support_files: []
- name: LB
containers:
- source: public
image_name: nginx
version: latest
cmd: ""
publish_events:
- name: Container nginx started
trigger: container-start
data: ""
subscriptions: []
config_files:
- filename: /etc/nginx/conf.d/default.conf
contents: |
server {
listen 80;
server_name {{repl ConfigOption "hostname" }};
keepalive_timeout 70;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://{{repl HostPrivateIpAddress "App" "freighter/counter" }}:{{repl ContainerExposedPort "App" "freighter/counter" "3000" }};
}
}
env_vars: []
ports:
- private_port: "80"
public_port: "80"
port_type: tcp
when: ""
volumes: []
support_files: []
- name: App
containers:
- source: public
image_name: freighter/counter
display_name: Freighter Counter
version: "1.0"
cmd: ""
publish_events:
- name: Container freighter/counter started
trigger: container-start
data: ""
subscriptions:
- component: LB
container: nginx
action: start
config_files: []
customer_files: []
env_vars:
- name: REDIS_HOST
static_val: "{{repl HostPrivateIpAddress \"DB\" \"redis\" }}"
- name: REDIS_PORT
static_val: "{{repl ContainerExposedPort \"DB\" \"redis\" \"6379\" }}"
ports: []
volumes: []
support_files: []
config:
- name: hostname
title: Hostname
description: Ensure this domain name is routable on your network.
items:
- name: hostname
title: Hostname
type: text
recommended: false
default: ""
when: ""
affix: ""
required: true
items: []
- name: backup
title: Backups
description: Backups are created in a directory on your host machine. You
can copy these to a safe place after a backup is made.
items:
- name: backup_path
title: Backup Path
required: true
type: text
default: /backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment