Skip to content

Instantly share code, notes, and snippets.

@pegasuskim
pegasuskim / redis_mysql_dump.js
Created January 31, 2018 01:07 — forked from gotomypc/redis_mysql_dump.js
Redis to MySQL dump
// modules
var redis = require('redis');
var Step = require('step');
// config file
var config = require('config');
// mysql client connect
var mysql = require('mysql');
var connection = mysql.createConnection({
@pegasuskim
pegasuskim / redis_mysql_dump.js
Created January 31, 2018 01:07 — forked from gotomypc/redis_mysql_dump.js
Redis to MySQL dump
// modules
var redis = require('redis');
var Step = require('step');
// config file
var config = require('config');
// mysql client connect
var mysql = require('mysql');
var connection = mysql.createConnection({
@pegasuskim
pegasuskim / redis-sentinel-failover.sh
Created April 3, 2018 06:13 — forked from holly/redis-sentinel-failover.sh
redis-sentinel client-reconfig-script
#!/bin/sh
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
MASTER_IP=$6
VIP=172.17.0.101
NETMASK=16
IF=eth0
MY_IP=$(ip addr show dev $IF | grep "global $IF" | head -1 | sed -e "s/^.*inet \(.*\)\/$NETMASK .*$/\1/")
#!/bin/sh
# redis-notify.sh
MAIL_FROM="[email protected]"
MAIL_TO="[email protected]"
if [ "$#" = "2" ]; then
mail_subject="Redis Notification"
mail_body=`cat << EOB
============================================
@pegasuskim
pegasuskim / redis-sentinel-switch-state.sh
Created April 5, 2018 08:42 — forked from waja/redis-sentinel-switch-state.sh
Shell script to migrate a VIP to the actual redis master when managing them with redis-sentinel
#!/bin/sh
_DEBUG="on"
DEBUGFILE=/tmp/sentinel_failover.log
VIP='10.125.125.30'
MASTERIP=${6}
MASK='24'
IFACE='eth0'
MYIP=$(ip -4 -o addr show dev ${IFACE}| grep -v secondary| awk '{split($4,a,"/");print a[1]}')
DEBUG () {
@pegasuskim
pegasuskim / __readme.md
Created August 8, 2018 01:38 — forked from maxivak/__readme.md
Building Docker image with Packer and provisioning with Ansible

Building Docker image with Packer and provisioning with Ansible

Overview

Packer

  • Packer is used to build image from a base image, perform provisions and store (commit) the final image.

  • We use provisioners and Packer templates to do the actual work to create the final image.

  • We use Ansible for provisioning.

@pegasuskim
pegasuskim / ansible-github.yml
Created August 13, 2018 06:40 — forked from devynspencer/ansible-github.yml
Example playbook for cloning a private git repository with Ansible.
---
hosts: all
tasks:
- name: add github ssh key
copy: >
src=files/id_rsa.github
dest=/root/.ssh/id_rsa.github
owner=root
group=root
@pegasuskim
pegasuskim / http-and-https-proxy.js
Created September 6, 2018 04:30 — forked from bnoordhuis/http-and-https-proxy.js
A node.js proxy that accepts HTTP and HTTPS traffic on the same port.
var fs = require('fs');
var net = require('net');
var http = require('http');
var https = require('https');
var httpAddress = '/path/to/http.sock';
var httpsAddress = '/path/to/https.sock';
fs.unlinkSync(httpAddress);
fs.unlinkSync(httpsAddress);
@pegasuskim
pegasuskim / haproxy
Created September 8, 2018 02:56 — forked from serainville/haproxy
#!/bin/sh
### BEGIN INIT INFO
# Provides: haproxy
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: fast and reliable load balancing reverse proxy
# Description: This file should be used to start and stop haproxy.
### END INIT INFO
@pegasuskim
pegasuskim / installHAProxy.sh
Created September 8, 2018 04:05 — forked from emgee3/installHAProxy.sh
Install HAProxy in Ubuntu 14.04 or 12.04
#!/usr/bin/env bash
#
# Install HAProxy
# Script works on Ubuntu 12.04 and 14.04 only
set -e
set -u
set -o pipefail