Skip to content

Instantly share code, notes, and snippets.

View modeyang's full-sized avatar

yangg modeyang

  • MongoTV
  • changsha
View GitHub Profile
@modeyang
modeyang / CeleryUtil.py
Created July 2, 2013 10:27
python celery
@celery.task
def create_book(name, pub_date):
Book.objects.create(name=name, pub_date=pub_date)
print Book.objects.all()
@modeyang
modeyang / MTWorker.py
Created July 2, 2013 10:43
mutlithread worker
#!/usr/bin/python
#coding=utf-8
import sys, os
import time
project_path = os.path.dirname(__file__)
project_path = os.path.join(project_path, '..')
sys.path.append(project_path)
import threading
from Queue import Queue, Empty as QueueEmpty
#!/usr/bin/python
#coding=utf-8
import sys, os
import time
project_path = os.path.dirname(__file__)
project_path = os.path.join(project_path, '..')
sys.path.append(project_path)
import threading
from Queue import Queue, Empty as QueueEmpty
#!/usr/bin/python
import psutil
import pyinotify
import os
import signal
class EventHandler(pyinotify.ProcessEvent):
def process_default(self, event):
if event.name.endswith(".conf"):
@modeyang
modeyang / elasticsearch.yml
Created June 24, 2016 02:46 — forked from reyjrar/elasticsearch.yml
ElasticSearch config for a write-heavy cluster
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
@modeyang
modeyang / install-pypy.sh
Created November 7, 2016 16:05 — forked from baoshan/install-pypy.sh
Install PyPy on CentOS
# yum list \*openssl\*
yum install -y openssl098e
yum install -y zlib
ln -s /usr/lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8
ln -s /usr/lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8
ln -s /lib64/libbz2.so.1 /lib64/libbz2.so.1.0
wget https://bitbucket.org/pypy/pypy/downloads/pypy-1.8-linux64.tar.bz2
tar -xf pypy-1.8-linux64.tar.bz2
cp -r pypy-1.8 /opt
ln -s /opt/pypy-1.8/bin/pypy /usr/local/bin
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Quotes around values are not supported, except in the case of
; the environment= options as shown below.
@modeyang
modeyang / elasticsearch-5.0.yml.j2
Last active August 25, 2017 09:57
elasticsearch-5.0.yml
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: {{ cluster_name }}
# Node can have abritrary attributes we can use for routing
@modeyang
modeyang / kafka-python.log
Created March 14, 2017 11:27
kafka-python error
^C2017-03-14 19:22:31,795 consumer.py [funcname:_maybe_auto_commit_offsets_sync] [line:405] ERROR Offset commit failed: This is likely to cause duplicate message delivery
Traceback (most recent call last):
File "/usr/local/python27/lib/python2.7/site-packages/kafka/coordinator/consumer.py", line 394, in _maybe_auto_commit_offsets_sync
self.commit_offsets_sync(self._subscription.all_consumed_offsets())
File "/usr/local/python27/lib/python2.7/site-packages/kafka/coordinator/consumer.py", line 379, in commit_offsets_sync
self._client.poll(future=future)
File "/usr/local/python27/lib/python2.7/site-packages/kafka/client_async.py", line 512, in poll
responses.extend(self._poll(timeout, sleep=sleep))
File "/usr/local/python27/lib/python2.7/site-packages/kafka/client_async.py", line 565, in _poll
response = conn.recv() # Note: conn.recv runs callbacks / errbacks
@modeyang
modeyang / elasticsearch-handlers-main.yml
Created March 16, 2017 21:13 — forked from labrown/elasticsearch-handlers-main.yml
Ansible rolling restart of Elasticsearch Cluster
---
###
# Elasticsearch Rolling restart using Ansible
###
##
## Why is this needed?
##
#
# Even if you use a serial setting to limit the number of nodes processed at one