朗志工作室(Langzhi Studio)

江浙沪一带找工作中,欢迎联系
方向:爬虫、搜索 技术:python,rails,node.js

  博客园 :: 首页 :: 联系 :: 订阅 订阅 :: 管理
  5662 Posts :: 2 Stories :: 515 Comments :: 7 Trackbacks

公告

2010年9月24日 #

今天快夜里12点查找百度收录,发现有836篇,

其中有9-4,9-10,9-11号的收录的数据

很多由于标题重复只显示了两面内容

posted @ 2010-09-24 23:57 lexus 阅读(20) 评论(0) 编辑

http://elixir.ematia.de/trac/wiki/Recipes/SQLAlchemySchemaMigration

http://code.google.com/p/sqlalchemy-migrate/

http://caneypuggies.alwaysreformed.com/wiki/DevelopingWithMigrations

document:

http://packages.python.org/sqlalchemy-migrate/

posted @ 2010-09-24 23:05 lexus 阅读(48) 评论(0) 编辑

This is a maintenance release for Python 0.13.0, fixing a number of
issues. Read the changelog for details:
http://www.gevent.org/changelog.html

Get it from PyPI: http://pypi.python.org/pypi/gevent

Thanks to Ralf Schmitt who worked with me on this release.

Thanks to the following people who provided patches: David Hain, Teh
Ekik, Dmitry Chechik, Alexey Borzenkov, Antoine Pitrou, Örjan Persson.

Thanks to everyone who reported bugs and participated in the discussion.

Thanks to Leif K-Brooks (Omegle.com) and Spotify (Spotify.com) who
responded to the sponsorship call and provided funds for gevent
development!

 

Release 0.13.1 (Sep 23, 2010)

Release highlights:

gevent.socket module:

gevent.ssl module:

  • Imported a number of patches from stdlib by Antoine Pitrou:
    • Calling makefile() method on an SSL object would prevent the underlying socket from being closed until all objects get truely destroyed (Python issue #5238).
    • SSL handshake would ignore the socket timeout and block indefinitely if the other end didn’t respond (Python issue #5103).
    • When calling getpeername() in SSLSocket.__init__, only silence exceptions caused by the “socket not connected” condition.
  • Added support for ciphers argument.
  • Updated SSLSocket.send and SSLSocket.recv methods to match the behavior of stdlib ssl better.
  • Fixed ssl.SSLObject to delete events used by other greenlets when closing the instance (issue #34).

Miscellaneous:

  • Made BaseServer accept long values as pool argument in addition to int.
  • Made http._requests attribute public.
  • Updated webchat example to use file on disk rather than in-memory sqlite database to avoid OperationalError.
  • Fixed webproxy.py example to be runnable under external WSGI server.
  • Fixed bogus failure in test__exc_info.py.
  • Added new test to check PEP8 conformance: xtest_pep8.py.
  • Fixed BackdoorServer close the connection on SystemExit and simplified the code.
  • Made Pool raise ValueError when initialized with size=0.
  • Updated setup.py --libevent to configure and make libevent if it’s not built already.
  • Updated setup.py to use setuptools if present and add dependency on greenlet.
  • Fixed doc/mysphinxext.py to work with Sphinx 1. Thanks by Örjan Persson.

The Last Release 0.13.0 (Jul 14, 2010)

 

posted @ 2010-09-24 19:27 lexus 阅读(106) 评论(0) 编辑

Mondrian has been ported to Google App Engine: Rietveld. It's open source (Apache license), you can deploy it on your app-engine account, or port to vanilla Django and deploy on your own server.

video

http://www.youtube.com/watch?v=sMql3Di4Kgc

 

 

An Open Source App: Rietveld Code Review Tool

Guido van Rossum
May 2008

Introduction

My first project as a Google engineer was an internal web app for code review. According to Wikipedia, code review is "systematic examination (often as peer review) of computer source code intended to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of software and the developers' skills." Not an exciting topic, perhaps, but the internal web app, which I code-named Mondrian after one of my favorite Dutch painters, was an overnight success among Google engineers (who evidently value software quality and skills development :-). I even gave a public presentation about it: you can watch the video on YouTube.

I've always hoped that we could release Mondrian as open source, but so far it hasn't happened: due to its popularity inside Google, it became more and more tied to proprietary Google infrastructure like Bigtable, and it remained limited to Perforce, the commercial revision control system most used at Google.

Fortunately, now that I work for the Google App Engine team, I've been able to write a new web app that incorporates many ideas (and even some code!) from Mondrian, and release it as open source. The Python open source community has been trying out Rietveld for the past few days, and has already been using it to do code reviews for Python (as well as providing valuable feedback in the form of bug reports and feature requests). Of course, the tool is not language-specific: you can use it for code reviews for any language!

Introducing Rietveld

To stick with the naming theme, I gave this new web app the code name Rietveld, after Gerrit Rietveld, one of my favorite Dutch architects and the designer of theZig-Zag chair. However, because most English speakers have trouble spelling his name correctly, the "live" web app is known simply as codereview.appspot.com.

The Rietveld app serves several purposes at once: it is a demo of fairly large-scale use of the popular web framework Django with App Engine, it makes some of the trickier (but portable) code we wrote for Mondrian available for reuse under the Apache 2.0 license, and it makes web-based code review available for many projects using Subversion repositories. Right now, any project hosted on Google Code can use Rietveld, as well as the Python subversion server. Support for arbitrary subversion servers is forthcoming.

While a public instance of Rietveld is running at codereview.appspot.com, organizations are of course free to run their own instance restricted and/or tailored to their own needs. That's what open source is for!

How Rietveld Manages Code Reviews

So what can you do with Rietveld? The basic workflow is:

  1. Developer makes some changes in their Subversion workspace.
  2. Developer uploads a patch in the form of svn diff output to Rietveld, using a small script named upload.py. This creates a new issue for them on the Rietveld website.
  3. Developer goes to the issue that was just created on the Rietveld site, adds the email addresses of one or more reviewers, and causes Rietveld to send an email to the reviewer(s).
  4. Reviewer navigates to the issue on the Rietveld site, browses the side-by-side diffs linked from there. A side-by-side diff shows the old and new version of the source code side by side, with deleted text on the left marked with a light red background, and inserted text on the right marked with a light green background. (Two different shades of red and green each are used, to highlight the differences at a finer-grain level than blocks of lines. This helps find one-character changes and clarifies diffs that just reflow a lot of text.)
  5. Reviewer inserts inline comments directly into the side-by-side diffs, by double-clicking lines on which they want to comment. Inline comments are initially created in draft mode, which means that only the comment author can see (and edit) them.
  6. Reviewer publishes comments, making them visible to everyone else, and sending an email to the developer (and to other reviewers) summarizing the inline comments with a little bit of context.

At this point, the developer can reply to inline comments directly on the Rietveld website using exactly the same mechanism as used by the reviewer. Replies simply become additional inline draft comments. The developer can also revise their code and upload a new version of the patch. The new version is attached to the same issue, and reviewers can choose to view the diffs afresh, or view the delta between the new and the old version of the patch. The latter feature is particularly helpful for large code reviews that require several iterations to reach agreement between developer and reviewer: the reviewer doesn't have to re-review stuff that didn't change between revisions and was already approved.

Coming Developments

I'm far from done with this application. Some features found in Mondrian that would be useful in Rietveld as well have not been implemented yet due to time constraints. The first users are also already asking for features I had never dreamed of, thanks to the many different styles of development found in the open source world. I have made the source code available as open source in this early stage in the hope to solicit outside contributions. My intention is to add outside developers to the project as soon as possible. As with Python, I am planning to remain in charge and review contributions carefully.

Links

Once more, codereview.appspot.com is the live web app, ready for your visits.

In the project home directory you can find some documentation and the complete source code.

For discussions, I've set up a Google Group: codereview-discuss.

In the bug tracker you can submit bugs and suggest feature requests.

Finally, here is the upload.py script mentioned above. Use Python 2.5.2 (or newer) to run it.

 

.net version http://malevich.codeplex.com/

posted @ 2010-09-24 19:24 lexus 阅读(81) 评论(0) 编辑

skip to navigation
skip to content

regex 0.1.20100918

Alternate regular expression module, to replace re.

Downloads ↓

Note

For testing and comparison with the current 're' module the new implementation is in the form of a module called 'regex'.

Please note that certain aspects of this module have changed from those of previous versions to make it conform better to the 're' module.

posted @ 2010-09-24 18:53 lexus 阅读(20) 评论(0) 编辑

http://sitemap.cn.yahoo.com/

posted @ 2010-09-24 12:19 lexus 阅读(28) 评论(0) 编辑

sudo easy_install dict4ini

 

ConfigParser模块是python自带的读取配置文件的模块.通过他可以方便的读取配置文件. 这篇文章简单介绍一下读取配置文件的方法.

配置文件.顾名思议就是存放配置的文件.下面是个例子
[info]
age = 21
name = chen
sex = male

其中[ ] 中的info是这段配置的名字
下面age,name都是属性

下面的代码演示了如何读取配置文件.和修改配置中变量的值

from __future__ import with_statement
import ConfigParser
config
=ConfigParser.ConfigParser()
with open('testcfg.cfg','rw') as cfgfile:
    config.readfp(cfgfile)
    name
=config.get('info','name')
    age
=config.get('info','age')
    
print name
    
print age
    config.set(
'info','sex','male')
    config.set(
'info','age','21')
    age
=config.get('info','age')
    
print name
    
print age

posted @ 2010-09-24 09:00 lexus 阅读(34) 评论(0) 编辑

http://djangopeople.net/

http://www.quarkbase.com/web-sites这个看着也清爽

posted @ 2010-09-24 07:23 lexus 阅读(14) 评论(0) 编辑

http://nowhiring.com.au/242552+resume+Supervisord+cleaner+VIC+Other.aspx

 

Supervisord cleaner

• Able to handle a variety of jobs at once • Flexibility • Attention to detail • Have a flexible and willing attitude • Work unsupervised • Excellent work history • Communication skills

Work Preferences

Desired Salary
20 - 35 per hour  
Availability
Immediately  
Desired Job Type
Full Time  
Can Travel for Work
Moderately  
Highest Education Level
High School  
Current Location
VIC Other  
Willing to relocate?
No
Residency / Visa
Authorised to work in Australia

Skills Profile

Admin / Secretarial / Office Support
Data Entry Clerk
Secretary
Trades & Services
Cleaner
Painting

Employment History

Job Title
Supervisor Cleaner
Industry
Other
02/2008 to 03/2010
Time management, stock taking, Training staff, laundry, prep,
Job Title
Labour
Industry
Construction
01/2006 to 11/2009
Prep work, gapping, sanding, cleaning,

Work Related Training & Certification

CompletedInstitutionTraining / Certification 
2002National CertificateComputing Level 2 & 3 

 

posted @ 2010-09-24 07:20 lexus 阅读(9) 评论(0) 编辑

http://supervisord.org/api.html xmprpc inovke api document

byteflow/django supervisord nginx = WIN

http://just-another.net/byteflowdjango-supervisord-nginx-win

 


urllib2 - The Missing Manual

HOWTO Fetch Internet Resources with Python

http://www.voidspace.org.uk/python/articles/urllib2.shtml#handling-exceptions <---很牛的py站

 

 

  #1  
Old 11-10-2009, 03:40 PM
I Got Nodes
 
Join Date: Aug 2009
Posts: 45
njmattes is on a distinguished road

Default How-To: Spawn PHP with supervisord (for NGINX on Debian)

 



Just to muddy the waters for people trying to decide between spawn-cgi and php-fpm, there's a third way to spawn php-cgi for NGINX. It's a process manager called supervisord, which will start any number of processes you want (you can use it for ssh, mysql, etc.) -- monitor them while they run, and restart them if they fail. I was previously using php-fpm, so that's reflected in some of the code below.

It can be slightly tricky, because it starts processes as sub-processes of itself. So any process you start with supervisord can't be running in daemon mode.

It's written in python and super easy to install.

Code:
aptitude install python-setuptools
easy_install supervisor

You need to make several modifications to your config file, which is located at /etc/supervisord.conf.

If you want to check the status of the supervisord processes through its wonderful web interface (make sure the port is open in iptables):

Code:
[supervisorctl]
serverurl=http://your.ip.add.ress:port
username=somename
password=somepass

Each process you want to start needs an entry in the config file. We'll start with PHP:

Code:
[fcgi-program:php-cgi]
command=/path/to/php-cgi
;socket=unix:///tmp/%program_name)s.sock
socket=tcp://127.0.0.1:9000
process_name=%(program_name)s_%(process_num)02d
user=www-data
numprocs=2
priority=999
autostart=true
autorestart=unexpected
startsecs=1
startretries=3
exitcodes=0,2
stopsignal=QUIT
stopwaitsecs=10

Socket needs to match the socket that NGINX is looking for. 127.0.0.1:9000 is pretty standard, but look at your nginx.conf file. The commented line is there if you want to listen on a unix socket instead.

I've been using supervisord to start all of the processes that I want monitored, so:

Code:
[program:sshd]
command=/path/to/sshd -D -e
process_name=%(program_name)s
autostart=true
autorestart=true

[program:postgres]
command=/path/to/postmaster -D "/path/to/databases"
process_name=%(program_name)s
stopsignal=INT
user=postgres
autostart=true
autorestart=true

[program:nginx]
command=/path/to/nginx
process_name=%(program_name)s
autostart=true
autorestart=true

For each program you start, you probably want to specify a log file, max size of the file, and amount of backups to rotate:

Code:
[program:someprogram]
redirect_stderr=true
stdout_logfile=/path/to/someprogram.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=10

Before you start supervisord, open your nginx.conf file and add this to the top, so it doesn't try to start in daemon mode:

Code:
daemon off;

Here's a simple init.d startup script for supervisord (put it her: /etc/init,d/supervisord):

Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides:          supervisor
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Starts/stops the supervisor daemon
# Description:       This starts and stops the supervisor dameon
#                    which is used to run and monitor arbitrary programs as
#                    services, e.g. application servers etc.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="supervisor daemon"
NAME="supervisor"
DAEMON="/usr/bin/${NAME}d"
SUPERVISORCTL="/usr/bin/${NAME}ctl"
PIDFILE="/var/run/${NAME}d.pid"
SCRIPTNAME="/etc/init.d/$NAME"
CONFFILE="/etc/${NAME}d.conf"

test -x "$DAEMON" || exit 0
test -r "$CONFFILE" || exit 0

if [ -r "/etc/default/$NAME" ]; then
    . "/etc/default/$NAME"
fi

set -e

d_start() {
    start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
        --exec "$DAEMON" \
        || echo -n " already running"
}

d_stop() {
    $SUPERVISORCTL shutdown
}

d_reload() {
    $SUPERVISORCTL reload
}

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    d_start
    echo "."
    ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    d_stop
    echo "."
    ;;
  reload|force-reload)
    echo -n "Reloading $DESC configuration..."
    d_reload
    echo "done."
  ;;
  restart)
    echo -n "Restarting $DESC: $NAME"
    d_stop
    sleep 1
    d_start
    echo "."
    ;;
  *)
    echo "Usage: "$SCRIPTNAME" {start|stop|restart|force-reload}" >&2
    exit 3
    ;;
esac

exit 0

Then:

Code:
chmod +x /etc/init.d/supervisord
update-rc.d supervisord defaults

If you're feeling randy, go ahead and remove the programs that supervisor will be starting from rc.d so they don't start twice when you reboot:

Code:
update-rc.d -f nginx remove
update-rc.d -f postgres remove
update-rc.d -f php-fpm remove
update-rc.d -f ssh remove

Then reboot, your VPS and eveything should be running. If you'd rather test it first, don't add ssh to your supervisord.conf file (I suppose you could get booted from your shell if anything goes haywire). Then:

Code:
/etc/init.d/nginx stop
/etc/init.d/postgres stop
/etc/init.d/php-fpm stop
/etc/init.d/supervisord start

If you go to the fancy web interface (set up above in the [supervisorctl] options), you should see what's running (hopefully everything) and what's not (hopefully nothing). Or you can run top or whatever command line utility you desire.

Now here's the scary part. Because every process is a sub-process of supervisord, if supervisord were to fail, it stands to reason that every process that it started will fail as well. So, and this might be overkill, I run monit as well. I use monit to watch supervisor. In monitrc:

Code:
check process supervisord
	with pidfile /path/to/supervisord.pid
	start program "/etc/init.d/supervisord start"
	stop program "/etc/init.d/supervisord stop"
	if failed unixsocket /tmp/supervisor.sock then restart
	if 5 restarts within 5 cycles then timeout

If monit goes down, and then supervisor goes down, then I guess I'm screwed. But I don't anticipate that happening. If you're prone to paranoia, you could daisy-chain runit, god, nagios, and who knows what else.

The whole process may seem a bit convoluted, but once you get it running it's wonderful. At least I think so.


Last edited by njmattes; 11-10-2009 at 04:14 PM.

Supervisord to manage your daemons

http://www.ivy.fr/blog/index.php/2009/12/21/106-supervisord-to-manage-your-daemons good ,deploy redis on supervisord

 

 

http://gist.github.com/593962 


an init.d script for supervisord

 

nginx / ngx_supervisord (project fully funded by megiteam.pl)
Module providing nginx with API to communicate with supervisordand manage (start/stop) backends on-demand.

As a "side effect", it also provides a way for dynamically taking backend servers out of rotation.

View:
README file,
CHANGES file,
APIv2 specification.

Download:
ngx_supervisord-1.4
(SHA1: e61f09244d30f3652f7276088470be2031b3666e)

GitHub repository:
http://github.com/FRiCKLE/ngx_supervisord/

Example configuration:

upstream backend {
	server 127.0.0.1:8000;
	server 127.0.0.1:8001;
	supervisord 127.0.0.1:9001 admin:super;
	fair;
}

server {
	location / {
		proxy_pass http://backend;
	}
}

 

 

 


superlance 0.5

superlance plugins for supervisord

Downloads ↓

superlance plugins for supervisor
=================================

Superlance is a package of plugin utilities for monitoring and
controlling processes that run under `supervisor
`_.

Currently, it provides two scripts:

``httpok`` -- This script can be used as a supervisor event listener
(subscribed to TICK events) which will restart a "hung" HTTP server
process, which is defined as a process in the RUNNING state which does
not respond in an appropriate or timely manner to an HTTP GET request.

``crashmail`` -- This script will email a user when a process enters
the EXITED state unexpectedly.

``memmon`` -- See the description below.

Memmon Overview
---------------

memmon is a supervisor "event listener" which may be subscribed to a
concrete TICK_x event. When memmon receives a TICK_x event (TICK_60 is
recommended, indicating activity every 60 seconds), memmon checks that a
configurable list of programs (or all programs running under supervisor) are
not exceeding a configurable about of memory (resident segment size, or RSS).
If one or more of these processes is consuming more than the amount of memory
that memmon believes it should, memmon will restart the process. memmon can be
configured to send an email notification when it restarts a process.

memmon is known to work on Linux and Mac OS X, but has not been tested on
other operating systems (it relies on ps output and command-line switches).

memmon is incapable of monitoring the process status of processes which are
not supervisord child processes.

Memmon Command
--------------

memmon is a "console script" installed when you install supervisor. Although
memmon is an executable program, it isn't useful as a general-purpose script:
it must be run as a supervisor event listener to do anything useful. memmon
accepts the following options:
综述性文章

 

 

 

posted @ 2010-09-24 00:42 lexus 阅读(65) 评论(0) 编辑

Ruby ForumNGINX > running nginx in the foreground

Posted by Joe Williams (zeusfaber
on 07.05.2008 17:55 
(Received via mailing list)
I have looked around of documentation on this but haven't found any. Is
it possible to keep the nginx master process from going into the
background/damonizing when starting it? I would like to have it run in
the foreground rather than becoming a daemon.

Thanks.
-Joe
Posted by Roxis (Guest) 
on 07.05.2008 18:28 
(Received via mailing list)
On Wednesday 07 May 2008, Joe Williams wrote:
> I have looked around of documentation on this but haven't found any. Is
> it possible to keep the nginx master process from going into the
> background/damonizing when starting it? I would like to have it run in
> the foreground rather than becoming a daemon.

daemon off
Posted by Joe Williams (zeusfaber
on 07.05.2008 18:48 
(Received via mailing list)
Thanks, that worked.

-joe

posted @ 2010-09-24 00:39 lexus 阅读(20) 评论(0) 编辑

We're Hiring!

We’re looking for a Django developer to join our team. With the impending departure of Armin Ronacher to finish his degree, we’re going to be at least one developer short this Fall. We’re looking for somebody who can jump right in and start contributing, primarily as a back-end Python/Django developer.

We’re a distributed company, so location does not matter. We like to hire managers of one and prefer people who are active in the Django open source community.

Initially, this will be a full-time (or as close as possible) contract position. If things work out, we’ve got a workload that can keep you around indefinitely. If you are interested, send an email to info@lincolnloop.com and include the following:

  • your resume or LinkedIn profile
  • links to open source code you’ve developed
  • your hourly rate

 

 

 

 

posted @ 2010-09-24 00:29 lexus 阅读(9) 评论(0) 编辑

http://semetricmedia.com/our-team

 

very IMPORTANT article reference:http://blog.crowproductions.de/2009/09/11/controlling-solr-with-supervisord/

 

Controlling Solr with supervisord

A while ago I found a solution to run Solr with supervisord, without leaking java processes, which you get when you use the generated solr-instance script with supervisord.

You need something like this in your supervisord.conf:

[program:solr]
directory = ${solr-instance:jetty-destination}/..
command = java -jar start.jar
autostart = true
autorestart = true

The key is the directory option. With that the command is executed in that directory, which starts Solr correctly and doesn’t leave java processes when stopping it with supervisord.

I discovered today that Solr, when used with collective.recipe.solrinstance, by default logs every query to stdout.

The solution is to change the command like the following:

command = java -Djava.util.logging.config.file=${buildout:directory}/etc/solr-logging.properties -jar start.jar

Now you just need to add the solr-logging.properties file with something like this as content:

# Default global logging level:
.level = WARNING

posted @ 2010-09-24 00:17 lexus 阅读(18) 评论(0) 编辑

sudo easy_install supervisor

它的配置文件使用;做为注释符

另外有点类似于nginx

使用supervisord -c supervisord.conf这样的方式在后台执行

使用supervisorctl进行命令行的控制,这个有点像redis

看了pycon上的视频,发现自已水平好菜,老外好牛,差距大,还没想到什么方法,只有多写代码来着。

 

以下reference:

http://lincolnloop.com/blog/2010/jun/24/automatically-running-supervisord-startup/

 

Automatically Running Supervisord on Startup

I really like supervisord for long-running process management. It is Python, so it is easy to install and it is easy to script with tools like Fabric. Lately I’ve been deploying smaller Django/WSGI sites with Green Unicorn behind Nginx proxied over a Unix socket which makes for a nice little setup on shared hosting and RAM starved VPSes.

After installing supervisord with something like sudo easy_install supervisor, you’ll want to make sure it runs after you reboot your machine (and gets restarted in case it crashes). If you are on a Linux system with upstart (and have root access), you can bypass the ugly init scripts and use this simple file placed in /etc/init/supervisord.conf to manage your supervisord process:

description     "supervisord"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

exec /usr/local/bin/supervisord --nodaemon --configuration /etc/supervisord.conf 

Now that it is in upstart, you can start it with the command sudo start supervisord.

If you are on shared hosting, you probably won’t have permissions to do this, but if you have access tocron, you can make sure it gets started in case the server reboots by adding this to your cron jobs:

@reboot	/my/path/to/supervisord -c /my/path/to/supervisord.conf 2>&1

In the event supervisord crashes or is killed off by a sysadmin, you’re out of luck. If this happens, you’ll want to look into having a cron job periodically poll the process pid to see if it is still alive and restart it if it is not. I haven’t needed this (yet), so that is left as an exercise for the reader :)

COMMENTS

  • June 24, 2010 at 12:56 p.m. #
    Simon Luijk responded:

    I am using daemontools to monitor gunicorn. When I update my code I send gunicorn a SIGHUP to gracefully reload the code. This creates all sorts of problems. As expected gunicorn starts up a new process and then shuts the original process down. At which point daemontools tries to start gunicorn as it thinks gunicorn has died. I have a tempary hack which I’ll spare you from.

    I have been looking for an alternative and supervisord is high on the list but I have not been able to find anything conclusive on sending signals to monitored processes. What is your experience in getting gunicorn to gracefully reload code with your setup?

  • June 25, 2010 at 4:48 a.m. #
    ZeissS chimed in with:

    @Simon: You could use the supervisorctl tool to signal supervisord to restart the process.

  • June 28, 2010 at 1:57 a.m. #
    Simon Luijk chimed in with:

    @ZeissS That would stop and start the process and not gracefully reload the code.

    I guess my question is does supervisord get its knickers in a twist if I “kill -HUP `cat /tmp/gunicorn.pid`” like daemontools does?

    Seeing that you can’t give supervisord a pid file for a process, I guess the answer is yes.

GOT SOMETHING TO SAY?

 

 

 

 

 

以下reference:http://blog.chinaunix.net/u2/87077/showart_2300645.html

使用supervisor监控进程
 
 
在linux下监控进程,可以使用inittab,最近找到了supervisor,也很好用,记录一下:
1、系统要安装python,并安装与之对应的setuptools,下载地址在此
2、安装:
# sh setuptoolsxxxx.egg
3、安装supervisor,下载地址在此,解压缩后
# python setup.py install
这就ok了,然后执行
# echo_supervisord_conf > /etc/supervisord.conf
修改/etc/supervisord.conf文件,加入你要监控的进程,里面的注释很详细,举个简单的例子:
这是一段要监控的进程的描述信息,添加到这个文件的末尾就好了:
[program:meta.txn.recover.on.error]
command=/cas/bin/meta.txn.recover.on.error ; 被监控的进程路径
numprocs=1                    ; 启动几个进程
directory=/cas/bin                ; 执行前要不要先cd到目录去,一般不用
autostart=true                ; 随着supervisord的启动而启动
autorestart=true              ; 自动重启。。当然要选上了
startretries=10               ; 启动失败时的最多重试次数
exitcodes=0                 ; 正常退出代码(是说退出代码是这个时就不再重启了吗?待确定)
stopsignal=KILL               ; 用来杀死进程的信号
stopwaitsecs=10               ; 发送SIGKILL前的等待时间
redirect_stderr=true          ; 重定向stderr到stdout
为了节省空间,注释的内容就不贴出来了。
执行
# supervisord -n
能在控制台看到监控进程的输出:
2010-08-17 10:26:07,467 INFO supervisord started with pid 943
2010-08-17 10:26:08,469 INFO spawned: 'meta.txn.recover.on.error' with pid 1009
2010-08-17 10:26:09,876 INFO success: meta.txn.recover.on.error entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2010-08-17 10:26:48,442 INFO exited: meta.txn.recover.on.error (terminated by SIGKILL; not expected)
2010-08-17 10:26:49,444 INFO spawned: 'meta.txn.recover.on.error' with pid 2427
2010-08-17 10:26:50,487 INFO success: meta.txn.recover.on.error entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
黑体的地方是我用kill -9杀掉进程后出来的,看到supervisor检测到进程退出后又再次启动了进程。
不带参数运行supervisord是以daemon方式运行。
把supervisord加入到开机启动项里就可以完成监控进程的功能了。


【注意】:当supervisord以非daemon方式运行时,杀掉supervisord后,被监控的进程也退出了。
而以daemon方式运行,杀掉supervisord对被监控进程无影响。

 

 

supervisor 管理后台进程

文章分类:Python编程

参考这篇文章 

加上一些notes: 

1 生成默认conf文件: echo_supervisord_conf > ... 

2 启动:superviserd -c 配置文件path 
     eg:supervised -c t.ini 
     配置文件ini格式 

3 控制:supervisorctrl -i 
     进入交互模式 

用 Supervisor 管理后台守护进程

一些虚拟主机支持跑后台守护程序, 比如 Webfaction.

在虚拟主机中管理后台守护程序没有 VPS 那么方便, VPS 是可以使用 root 权限的, 但虚拟主机则不能.

要更方便的管理后台进程, 通常需要借助一些辅助工具. 常用的管理工具有 runitdaemontools 以及 Supervisor. 其中以 Supervisor 最为易用, 功能也很完善.

安装 Supervisor

Supervisor 是一个 Python 程序, 按照 官方文档安装 就可以了.

稍加注意的是, 虚拟主机用户需要安装到他的用户目录:

easy_install supervisor --prefix=$HOME

安装完成后, 确保 $HOME/bin 目录在 $PATH 环境变量中并已经生效.

使用方法: 以 Zine 为例

Zine 可以作为后台守护程序运行, 通过 Supervisor 进行 启动/重启/失败自动重启 等控制.

Supervisor 有两个可执行程序 — supervisord 和 supervisorctl:

  • supervisord 是后台管理服务器, 用来依据配置文件的策略管理后台守护进程;
  • supervisorctl 用于管理员向后台管理程序发送 启动/重启/停止 等指令;

它们之间的关系就相当于 Apache 的 httpd 和 apachectl.

创建工作目录和配置文件

首先需要创建一个 Supervisor 的工作目录, 如: $HOME/deploy/supervisor/, 用来存放错误日志输出, pid 文件, socket 文件, 配置文件等.

接着是创建 配置文件, 配置文件用来指示 Supervisor 有哪些进程需要管理, 以及管理策略.

我们把配置文件命名为 supervisord.conf (也可以是其它任何文件名, 但 Supervisor 默认自动在当前目录查找该文件, 用 supervisord.conf 会为以后管理提供方便):

[supervisord]
logfile = %(here)s/supervisord.log
loglevel = warn
pidfile = %(here)s/supervisord.pid
directory = %(here)s/
childlogdir = %(here)s/childlog

[unix_http_server]
file = <YOU-HOME-PATH>/deploy/supervisor/supervisord.sock

[rpcinterface:supervisor]
; This section is always necessary because supervisor uses RPC internally.
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
; Must match settings in 'unix_http_server'
serverurl = unix:///<YOU-HOME-PATH>/deploy/supervisor/supervisord.sock

[program:blog]
command = <YOU-HOME-PATH>/deploy/zine/bin/python /home/yospaly/deploy/zine/scripts/server -a 127.0.0.1 --no-reloader --no-debugger --threaded -p 6666 -I <YOU-HOME-PATH>/deploy/blog/

[program:blog2]
command = <YOU-HOME-PATH>/deploy/zine/bin/python /home/yospaly/deploy/zine/scripts/server -a 127.0.0.1 --no-reloader --no-debugger --threaded -p 8888 -I <YOU-HOME-PATH>/deploy/blog2/
  • 配置文件的第一段用来配置 supervisord 后台管理服务器一些输出文件的路径;
  • 第二段用来打开 supervisord 内部的 Socket 服务, 以便接受和处理来自控制程序 (supervisorctl) 请求;
  • 第三段是必备的, 详见注释;
  • 第四段告诉控制程序 (supervisorctl) 通过什么途径和 supervisord 通信;

Note

Webfaction 的用户不能随意指定 Zine 的端口号, 要使用在 Webfaction 控制面板添加新的 “Custom app (listening on port)” 后获得的一个特定端口号.

使用 supervisorctl 进行控制

在 supervisord.conf 所在的工作目录执行 supervisord 运行后台管理服务器, 如果运行失败请查看工作目录下的错误日志;

supervisord 跑起来后, supervisorctl 就可以方便的手工管理守护程序了:

supervisorctl start all
supervisorctl stop blog
supervisorctl restart blog2

结束语

Supervisor 是一个易用, 又不失强大的工具, 这里只涉及了 Supervisor 最基本的使用, 还有很多更加高级和有用的功能未能覆盖, 可以进一步参考 Supervisor 官方文档.

2009-05-14, Thursday 17:42 PM | 0 comments 0 pingbacks | Tags: 

 

posted @ 2010-09-24 00:16 lexus 阅读(76) 评论(0) 编辑