Skip to content

Instantly share code, notes, and snippets.

check process redis-server
with pidfile "/var/run/redis.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
@likai24
likai24 / README.md
Created June 10, 2016 00:23 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@likai24
likai24 / logger.sh
Last active June 23, 2016 04:27
一个用来打印日志输出的脚本
#!/usr/bin/env bash
#
# This is to print nice logs
#
# @version : 0.0.1
#
#
#############################################
# Environment variables and their defaults
@likai24
likai24 / help.sh
Created June 23, 2016 04:27
用来打印help的脚本
#!/usr/bin/env bash
#
# help function
#
# @version : 0.0.1
#
#
#############################################
function help () {
echo -e "\033[1m${1}\033[0m" 1>&2
@likai24
likai24 / tpl.sh
Created June 23, 2016 04:29
简单的模板脚本
#!/usr/bin/env bash
# This file is to setup nginx for php application
#
# @Version : 0.0.1
# @Usage : tpl.sh template
# can not be used to render bash script, use sed instead
#
set -o pipefail
set -o errexit
# set -o xtrace
@likai24
likai24 / setup_nginx.sh
Created June 23, 2016 04:31
一个使用模板脚本tpl.sh的例子
#!/usr/bin/env bash
# This file is to setup nginx for php application
# @Version : 0.0.1
# @Usage : ./setup.sh [appname] [server_name] [port] [fpm_port]
# @Example : ./setup.sh oa_attr attr.meikecheng.com 80 9023
#
set -o pipefail
set -o errexit
# set -o xtrace
@likai24
likai24 / check_installed.sh
Created June 23, 2016 04:35
检查软件有没有安装
# check whether git is installed
command -v git >/dev/null 2>&1 || { echo >&2 "git is required but it's not installed. Aborting."; exit 1; }
# check node
check_node=$(which node);
if [[ -z $check_node ]];
then
# install_node
else
echo 'Node Already Installed';
@likai24
likai24 / setup_app.sh
Created June 23, 2016 04:38
展示了接受参数的方法
#!/usr/bin/env bash
#
# @version : 0.0.1
#
#####################
# Global Configuration
set -o pipefail
set -o errexit
@likai24
likai24 / get_opt.sh
Created June 26, 2016 06:04
获取参数设置
#!/bin/bash
aflag=no
bflag=no
flist=""
set -- $(getopt abf "$@")
while [ $# -gt 0 ]
do
case "$1" in
-a) echo 1;;
-b) echo 2;;
@likai24
likai24 / check_init.sh
Created June 27, 2016 17:23
检查系统的启动命令
#!/bin/bash
# from http://unix.stackexchange.com/questions/18209/detect-init-system-using-the-shell
if [[ `/sbin/init --version` =~ upstart ]]; then echo using upstart;
elif [[ `systemctl` =~ -\.mount ]]; then echo using systemd;
elif [[ -f /etc/init.d/cron && ! -h /etc/init.d/cron ]]; then echo using sysv-init;
else echo cannot tell; fi