EnglezăFrancezăSpaniolă

Ad


Favicon OnWorks

circ - Online in the Cloud

Run circus in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

Acesta este circuitul de comandă care poate fi rulat în furnizorul de găzduire gratuit OnWorks folosind una dintre multiplele noastre stații de lucru online gratuite, cum ar fi Ubuntu Online, Fedora Online, emulator online Windows sau emulator online MAC OS

PROGRAM:

NUME


circ - Documentație circ [imagine]

Circus este un program Python care poate fi folosit pentru a monitoriza și controla procesele și socket-urile.

Circul poate fi condus printr-o interfață de linie de comandă, o interfață web sau programatic
prin API-ul său python.

Pentru a-l instala și a încerca caracteristicile sale, consultați exemplele sau citiți restul acestei pagini
pentru o introducere rapidă.

ALERGARE A CIRC DAEMON


Circus oferă un apel de script în linia de comandă circ care poate fi folosit pentru a gestiona procese
organizate în unul sau mai mulți observatori.

Instrumentul de linie de comandă al lui Circus este configurabil folosind un fișier de configurare în stil ini.

Iată un exemplu foarte minim:

[watcher:program]
cmd = python myprogram.py
numprocese = 5

[observator:un alt program]
cmd = alt_program
numprocese = 2

Fișierul este apoi transmis la circ:

$ circusd exemplu.ini

Pe lângă procese, Circus poate lega și prize. Întrucât fiecare proces gestionat de Circus este
un copil al demonului principal Circus, asta înseamnă că orice program controlat de Circus poate
utilizați acele prize.

Rularea unei prize este la fel de simplă ca și adăugarea unui priză secțiunea din fișierul de configurare:

[socket:mysocket]
gazdă = gazdă locală
port = 8080

Pentru a afla mai multe despre prize, consultați prize.

Pentru a înțelege de ce este o caracteristică ucigașă, citiți de ce prize de circ.

CONTROLUL CIRC


Circus oferă două instrumente de linie de comandă pentru a gestiona demonul care rulează:

· circ, o consolă de management pe care o puteți utiliza pentru a efectua acțiuni precum adăugarea sau
scoaterea muncitorilor

· blatul de circ, o consolă de top pe care o puteți folosi pentru a afișa memoria și utilizarea procesorului dvs
alergând Circul.

Pentru a afla mai multe despre acestea, vezi cli

Circus oferă, de asemenea, un tablou de bord web care se poate conecta la un daemon Circus care rulează și vă poate permite
monitorizează și interacționează cu acesta.

Pentru a afla mai multe despre această funcție, consultați circushttpd

Ce acum ?
Dacă sunteți dezvoltator și doriți să utilizați Circus în propriul proiect, scrieți pluginuri sau
cârlige, du-te la fordevs.

Dacă sunteți operator și doriți să vă gestionați procesele folosind Circus, accesați forops.

Contribuții și Feedback
Mai multe despre contribuții: contribuții.

Link-uri utile:

· Există o listă de corespondență pentru orice feedback sau întrebare:
http://tech.groups.yahoo.com/group/circus-dev/

· Depozitul și instrumentul de urmărire a problemelor sunt pe GitHub : https://github.com/circus-tent/circus

· Alăturați-vă nouă pe IRC: Freenode, canal #cort-circ

Documentație index
Instalarea Circ
Circus este un pachet Python care este publicat pe PyPI - Indexul pachetelor Python.

Cel mai simplu mod de a-l instala este să folosești pip, un instrument pentru instalarea și gestionarea Python
pachete:

$ pip install circ

Sau descărcați Arhiva on PyPI, extrageți-l și instalați-l manual cu:

$ python setup.py install

Dacă doriți să încercați Circul, vedeți exemplele.

Dacă utilizați debian sau orice distribuție bazată pe Debian, puteți folosi și ppa pentru
instala circ, este la https://launchpad.net/~roman-imankulov/+archive/circus

zc.buildout
Oferim un zc.buildout configurație, o puteți utiliza pur și simplu rulând bootstrap
script, apoi apelând buildout:

$ python bootstrap.py
$ bin/buildout

Mai Mult on Cerinţe
Circul lucrează cu:

· Python 2.6, 2.7, 3.2 sau 3.3

·

zeromq >= 2.1.10

· Versiunea de zeromq acceptată este determinată în cele din urmă de ce versiune
pyzmq este instalat prin pip în timpul instalării circului.

· Lansarea lor actuală acceptă versiunile 2.x (limitate), 3.x și 4.x ZeroMQ.

· notițe: Dacă utilizați PyPy în loc de CPython, asigurați-vă că le citiți
documentele de instalare, deoarece suportul pentru versiunea ZeroMQ nu este același pe PyPy.

Când instalați circ, cele mai recente versiuni ale dependențelor Python vor fi scoase
pentru tine.

De asemenea, le puteți instala manual folosind fișierul pip-requirements.txt pe care îl oferim:

$ pip install -r pip-requirements.txt

Dacă doriți să rulați consola Web, va trebui să instalați circ-web:

$ pip install circ-web

tutorial
Pas cu pas tutorial
exemple director în depozitul Circus conține multe exemple pentru a vă obține
a început, dar iată un tutorial complet care vă oferă o privire de ansamblu asupra funcțiilor.

Vom supraveghea o aplicație WSGI.

Instalare
Circus este testat pe Mac OS X și Linux cu cele mai recente Python 2.6, 2.7, 3.2 și 3.3. La
conduceți un circ complet, veți avea nevoie de asemenea libzmq, libevent & virtualenv.

Pe sisteme bazate pe Debian:

$ sudo apt-get install libzmq-dev libevent-dev python-dev python-virtualenv

Creați un virtualenv și instalați circ, circ-web și ciorap în ea

$ virtualenv /tmp/circus
$ cd /tmp/circ
$ bin/pip install circ
$ bin/pip install circus-web
$ bin/pip install chassette

Odată ce ați făcut acest lucru, veți găsi o multitudine de comenzi în directorul bin local.

Folosire
chaussette vine cu o aplicație implicită Hello world, încercați să o rulați:

$ bin/chaussette

Ar trebui să poți vizita http://localhost: 8080 si vezi Alo lume.

Opriți Chaussette și adăugați un fișier circus.ini în directorul care conține:

[circ]
statsd = 1
httpd = 1

[watcher:webapp]
cmd = bin/chaussette --fd $(circus.sockets.web)
numprocese = 3
use_sockets = Adevărat

[socket:web]
gazdă = 127.0.0.1
port = 9999

Acest fișier de configurare îi spune lui Circus să lege un socket pe port 9999 si ruleaza 3 muncitori sasete
impotriva. De asemenea, activează tabloul de bord web Circus și modulul de statistici.

Salvați-l și rulați-l folosind circ:

$ bin/circusd --daemon circus.ini

Acum vizitați http://127.0.0.1: 9999, ar trebui să vedeți aplicația hello world. Diferența este acum
că socket-ul este gestionat de Circus și există mai mulți lucrători web care acceptă
conexiuni împotriva acestuia.

NOTĂ:
Echilibrarea sarcinii este operată de sistemul de operare, astfel încât obțineți aceeași viteză
ca orice alt server web pre-fork, cum ar fi Apache sau NGinx. Circul nu interferează cu
datele prin care trec.

De asemenea, puteți vizita http://localhost: 8080 / și bucurați-vă de tabloul de bord web Circus.

Interacțiune
Să folosim shell-ul circusctl în timp ce sistemul rulează:

$ bin/circusctl
circ 0.7.1
circusd-stats: activ
circhttpd: activ
aplicație web: activă
(circul)

Intri într-un shell interactiv. Tip ajutor pentru a obține toate comenzile:

(circusctl) ajutor

Comenzi documentate (tastați help ):
========================================
add get list numproceses ieșire rm start stop
decr globaloptions asculta numwatchers reîncarcă set statistici
dstats incr listsockets opțiuni starea semnalului de repornire

Comenzi nedocumentate:
======================
Ajutor EOF

Să încercăm lucruri de bază. Să enumerăm procesele lucrătorilor web și să adăugăm unul nou:

(circusctl) listă aplicație web
13712,13713,13714
(circusctl) incr webapp
4
(circusctl) listă aplicație web
13712,13713,13714,13973

Felicitări, ai interacționat cu Circul tău! Ieșiți din shell cu Ctrl+D și acum rulați
blat de circ:

$ bin/circus-top

Aceasta este o comandă de top pentru a urmări memoria tuturor proceselor și utilizarea procesorului în timp real.

Apăsați Ctrl+C și acum să părăsim complet Circus prin circus-ctl:

$ bin/circusctl ieșire
ok

Pagina Următoare → paşi
Puteți conecta propria dvs. aplicație WSGI în loc de lumea bună a lui Chaussette pur și simplu
indicând aplicația apelabilă.

Chaussette vine și cu multe backend-uri precum Gevent sau Meinheld.

Citeste https://chaussette.readthedocs.org/ pentru toate opțiunile.

De ce I utilizare Circ in schimb of X ?
1. Circ Simplifică ta web stivui proces administrare

Circul știe să gestioneze procesele și socket-uri, deci nu trebuie să delegați web
managementul lucrătorilor către un server WGSI.

Vezi de ce prize de circ

2. Circ furnizează pub/sub și sondaj notificări de ZeroMQ
Circus are un canal pub/sub la care te poți abona. Acest canal primește toate evenimentele
care se întâmplă la Circ. De exemplu, puteți fi notificat atunci când un proces se stinge sau
construi un client care declanșează un avertisment atunci când unele procese consumă tot procesorul sau
BERBEC.

Aceste evenimente sunt trimise printr-un canal ZeroMQ, ceea ce îl face diferit de stdin
Supravegherea fluxului utilizează:

· Circul trimite evenimente într-o manieră „foc și uita”, deci nu este nevoie să faci bucla manual
prin toate ascultători și își mențin stările.

· Abonații pot fi localizați pe o gazdă la distanță.

Circus oferă, de asemenea, modalități de a obține actualizări de stare prin sondaje unice la cerere/repetiție
canal. Aceasta înseamnă că vă puteți obține informațiile fără a fi nevoie să vă abonați la un
curent. Comanda cli furnizată de Circus utilizează acest canal.

Vezi exemple.

3. Circ is (Piton) dezvoltator prietenos
În timp ce Circus poate fi condus în întregime de un fișier de configurare și circ / circ
comenzi, este ușor să reutilizați întregul sau o parte a sistemului pentru a vă construi propriul personalizat
Proces Watcher în Python.

Fiecare strat al sistemului este izolat, astfel încât să puteți reutiliza independent:

· ambalajul procesului (Proces)

· managerul de procese (Watcher)

· managerul global care conduce mai mulți manageri de procese (Arbitru)

· și așa mai departe…

4. Circ cântare
Unul dintre cazurile de utilizare ale Circus este gestionarea a mii de procese fără a adăuga
overhead -- suntem dedicați să ne concentrăm asupra acestui lucru.

Venire din Supraveghetor
Supervisor este o soluție foarte populară în lumea Python și suntem adesea întrebați cum este Circus
se compară cu acesta.

Dacă vii de la Supraveghetor, această pagină încearcă să ofere o imagine de ansamblu asupra modului în care instrumentele
diferă.

Diferențele Prezentare generală
Supervisor și Circus au aceleași obiective - ambii gestionează procesele și oferă a
script de linie de comandă — respectiv supraveghetor și circ — care citește o configurație
fișier, furnizează procese noi și le menține în viață.

Circus are o caracteristică suplimentară: capacitatea de a lega prize și de a lăsa procesele pe care le gestionează
utilizati-le. Acest model de „pre-furcătură” este folosit de multe servere web, cum ar fi Apache or
Inorog. Având această opțiune în Circus, puteți simplifica o stivă de aplicații web: toate procesele și
prizele sunt gestionate de un singur instrument.

Ambele proiecte oferă o modalitate de a controla un daemon care rulează printr-un alt script. respectiv
supraveghetorctl și circ. De asemenea, ambii au evenimente și o modalitate de a vă abona la ele.
Principala diferență este tehnologia de bază: Supervisor folosește XML-RPC pentru interacțiune
cu demonul, în timp ce Circus folosește ZeroMQ.

Circus și Supervisor au ambele o interfață web pentru a afișa ceea ce se întâmplă. Circul este mai mult
avansat, deoarece puteți urmări în timp real ceea ce se întâmplă și interacționați cu demonul.
Utilizează socket-uri web și este dezvoltat într-un proiect separat (circ-web.)

Există multe alte diferențe subtile în designul de bază, am putea enumera aici într-o zi... În
Între timp, puteți afla mai multe despre elementele interne ale circului în design.

Configuraţie
Ambele sisteme folosesc un fișier asemănător ini ca configurație.

· Supraveghetor documentaţie

· Circ documentaţie

Iată un mic exemplu de rulare a unei aplicații cu Supervisor. În acest caz,
aplicația va fi pornită și repornită în cazul în care se blochează

[program:exemplu]
comanda=npm start
director=/home/www/serverul-meu/
user=www-data
autostart = adevărat
pornire automată=adevărat
redirect_stderr=Adevărat

În Circus, aceeași configurație se realizează prin:

[observator:exemplu]
cmd=npm start
work_dir=/home/www/my-server/
user=www-data
stderr_stream.class=StdoutStream

Observați că redirecționarea stderr este ușor diferită în Circus. Instrumentul nu are
a coadă caracteristică ca în Supervisor, dar vă va permite să conectați orice bucată de cod cu care să vă ocupați
fluxul de intrare. Puteți să vă creați propriul cârlig de flux (ca o clasă) și să faceți orice doriți
doresc cu fluxul de intrare. Circus oferă câteva clase de flux încorporate, cum ar fi
StdoutStream, FileStream, VizionatFileStream, Sau TimedRotatingFileStream.

Circ pentru Ops
AVERTISMENT:
În mod implicit, Circus nu își securizează mesajele atunci când trimite informații prin ZeroMQ.
Înainte de a rula Circus într-un mediu de producție, asigurați-vă că citiți pagina Securitate.

Primul pas pentru a gestiona un daemon Circus este să scrieți fișierul de configurare al acestuia. Vedea
configurație. Dacă implementați o stivă web, aruncați o privire la socket-uri.

Circus poate fi implementat folosind Python 2.6, 2.7, 3.2 sau 3.3 - majoritatea implementărilor există
făcut în 2.7. Pentru a afla cum să implementați Circus, consultați implementarea.

Pentru a gestiona un daemon Circus, ar trebui să vă familiarizați cu lista de comenzi pe care o puteți utiliza
in circ. Observați că puteți avea același ajutor online atunci când alergați circ ca o
coajă.

De asemenea, oferim blatul de circ, vezi cli și un tablou de bord web frumos. vezi circhttpd.

În sfârșit, pentru a profita la maximum de Circus, asigurați-vă că verificați cum să utilizați pluginuri și cârlige.
Vedeți pluginuri și cârlige.

Ops documentaţie index
Configuraţie
Circus poate fi configurat folosind un fișier de configurare în stil ini.

Exemplu:

[circ]
check_delay = 5
punct final = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
include = \*.more.config.ini
umask = 002

[watcher:myprogram]
cmd = python
args = -u myprogram.py $(circus.wid) $(CIRCUS.ENV.VAR)
întârziere_încălzire = 0
numprocese = 5

# cârlig
hooks.before_start = my.hooks.control_redis

# va introduce test.log fluxul la fiecare 300 ms
stdout_stream.class = FileStream
stdout_stream.filename = test.log

# opțional rotiți fișierul jurnal când ajunge la 1 GB
# și salvați 5 copii de fișiere rotite
stdout_stream.max_bytes = 1073741824
stdout_stream.backup_count = 5

[env:myprogram]
PATH = $PATH:/ cos
CAKE = minciuna

[plugin:statsd]
use = circus.plugins.statsd.StatsdEmitter
gazdă = gazdă locală
port = 8125
rata_eșantionului = 1.0
application_name = exemplu

[socket:web]
gazdă = gazdă locală
port = 8080

circ - singur secțiune
punct final
Priza ZMQ folosită pentru a gestiona Circus prin circ. (Mod implicit:
tcp://127.0.0.1:5555)

endpoint_owner
Dacă este setat la un nume de utilizator de sistem și punctul final este un socket ipc asemănător
ipc://var/run/circusd.sock, atunci proprietatea fișierului socket va fi schimbată în
acel utilizator la pornire. Pentru mai multe detalii, consultați securitate. (implicit: niciunul)

pubsub_endpoint
Priza ZMQ PUB/SUB primește publicații ale evenimentelor. (Mod implicit:
tcp://127.0.0.1:5556)

papa_endpoint
Dacă utilizați papa, puteți specifica punctul final, cum ar fi ipc://var/run/circusd.sock.
(Mod implicit: tcp://127.0.0.1:20202)

statsd Dacă este setat la True, Circus rulează demonul circusd-stats. (implicit: fals)

stats_endpoint
Priza ZMQ PUB/SUB primește publicații de statistici. (Mod implicit:
tcp://127.0.0.1:5557)

statsd_close_outputs
Dacă True trimite circusd-stats stdout/stderr la /dev/null. (implicit: fals)

check_delay
Intervalul de interogare în secunde pentru soclul ZMQ. (implicit: 5)

include
Lista fișierelor de configurare de inclus. Puteți folosi metacaracterele (*) pentru a include particular
scheme pentru fișierele dvs. Căile sunt absolute sau relative la fișierul de configurare.
(implicit: niciunul)

include_dir
Lista directoarelor de configurare. Toate fișierele se potrivesc * .ini sub fiecare director va
a fi inclus. Căile sunt absolute sau relative la fișierul de configurare. (Mod implicit:
Nici unul)

stream_backend
Definește tipul de backend de utilizat pentru streaming. Valorile posibile sunt fir
or gevent. (implicit: fir)

întârziere_încălzire
Începe intervalul în secunde dintre doi observatori. Trebuie să fie un int. (implicit: 0)

httpd Dacă este setat la True, Circus rulează demonul circushttpd. (implicit: fals)

httpd_host
Gazda condusă de demonul circushttpd. (implicit: localhost)

httpd_port
Portul rulat de demonul circushttpd. (implicit: 8080)

httpd_close_outputs
Dacă este adevărat, trimite circushttpd stdout/stderr la /dev/null. (implicit: fals)

depana Dacă setați la True, toți demonii Circus stout/stderr sunt redirecționați către circusd
stdout/stderr (implicit: False)

debug_gc
Dacă este setat la True, circusd scoate informații suplimentare din jurnal de la colectorul de gunoi.
Acest lucru poate fi util în urmărirea scurgerilor de memorie. (implicit: fals)

pidfile
Fișierul care trebuie utilizat pentru a păstra pid-ul demonului.

masca Valoare pentru umask. Dacă nu este setat, circusd nu va încerca să modifice umask.

nivel de jurnal
Nivelul de jurnal pe care vrem să-l vedem (implicit: INFO)

ieșire
Fișierul de ieșire în logare în care dorim să ne logăm (implicit: - pentru a vă conecta stdout). Puteți
conectați-vă la un syslog la distanță utilizând următoarea sintaxă:
syslog://gazdă:port?facilitate unde host este serverul dvs. syslog, portul este opțional
iar facilitate este facilitatea syslog de utilizat. Dacă doriți să vă conectați la un syslog local
poți să folosești syslog:///path/to/syslog/socket?facility in schimb.

loggerconfig
O cale către un fișier INI, JSON sau YAML pentru a configura înregistrarea standard Python pentru
Arbitru. Valoarea specială „implicit” folosește configurația de înregistrare încorporată
pe baza opțiunilor opționale de loglevel și logoutput.

Exemplu YAML Configuraţie Fișier

Versiune: 1
disable_existing_loggers: false
formatoare:
simplu:
format: „%(asctime)s - %(name)s - [%(levelname)s] %(message)s”
manipulatori:
fișier jurnal:
clasa: logging.FileHandler
nume de fișier: logoutput.txt
nivel: DEBUG
formatator: simplu
loggeri:
circ:
nivel: DEBUG
handlere: [fișier jurnal]
propagare: nu
rădăcină:
nivel: DEBUG
handlere: [fișier jurnal]

observator:NAME - as multe secțiuni as tu vrea
NUME Numele observatorului. Acest nume este folosit în circ

cmd Programul executabil de rulat.

args Argumente din linia de comandă de transmis programului. Puteți utiliza formatul python
sintaxa aici pentru a construi parametrii. Variabilele de mediu sunt disponibile, cum ar fi
precum și ID-ul lucrătorului și variabilele de mediu pe care le-ați transmis, dacă există,
cu parametrul „env”. Vedea Formatarea il comenzi și argumente cu dinamic
variabile Pentru mai multe informații în acest sens.

coajă Dacă este adevărat, procesele sunt rulate în shell (implicit: False)

shell_args
Argumente din linia de comandă de transmis comenzii shell când coajă este adevarat. Lucrări
numai pentru sistemul *nix (implicit: Nici unul)

dir_de lucru
Directorul de lucru pentru procese (implicit: Nici unul)

uid ID-ul utilizatorului sau numele cu care ar trebui să ruleze comanda. (Uid-ul curent este
Mod implicit).

ghid ID-ul grupului sau numele cu care ar trebui să ruleze comanda. (Ghidul actual este
Mod implicit).

copy_env
Dacă este setată la true, variabilele de mediu locale vor fi copiate și transmise la
lucrătorilor atunci când le depun. (Implicit: fals)

copy_path
Dacă este setat la adevărat, sys.path este transmis în mediul subprocesului folosind PYTHONPATH.
copy_env trebuie să fie adevărat. (Implicit: fals)

întârziere_încălzire
Întârzierea (în secunde) dintre procesele de rulare.

autostart
Dacă este setat la fals, observatorul nu va fi pornit automat când arbitrul
începe. Observatorul poate fi pornit explicit (exemplu: circusctrl Începe
programul meu). (Implicit: Adevărat)

numprocese
Numărul de procese de rulat pentru acest observator.

rlimit_LIMIT
Setați limita de resurse LIMIT pentru procesele urmărite. Numele de configurare ar trebui să se potrivească
constantele RLIMIT_* (nu țin cont de majuscule și minuscule) enumerate în Piton resursă modul
referință. De exemplu, linia de configurare „rlimit_nofile = 500” stabilește valoarea maximă
numărul de fișiere deschise la 500. Pentru a seta o valoare limită la RLIM_INFINITY, nu setați un
valoare, ca această linie de configurare: 'rlimit_nofile = '.

stderr_stream.class
Un nume de clasă Python complet calificat care va fi instanciat și va primi
il stderr fluxul tuturor proceselor din ea __apel__() metodă.

Circus oferă câteva clase de flux pe care le puteți folosi fără prefix:

· FileStream: scrie într-un fișier și poate face rotația automată a jurnalului

· VizionatFileStream: scrie într-un fișier și se bazează pe rotația jurnalului extern

· TimedRotatingFileStream: scrie într-un fișier și se poate roti la un anumit timp
intervale.

· QueueStream: scrieți într-o coadă de memorie

· StdoutStream: scrie în stdout

· FancyStdoutStream: scrie ieșire colorată cu prefixe de timp în stdout

stderr_stream.*
Toate opțiunile începând cu stderr_stream. altele decât clasă va fi trecut de
constructor la crearea unei instanțe a clasei definite în
stderr_stream.class.

stdout_stream.class
Un nume de clasă Python complet calificat care va fi instanciat și va primi
il stdout fluxul tuturor proceselor din ea __apel__() metodă.

Circus oferă câteva clase de flux pe care le puteți folosi fără prefix:

· FileStream: scrie într-un fișier și poate face rotația automată a jurnalului

· VizionatFileStream: scrie într-un fișier și se bazează pe rotația jurnalului extern

· TimedRotatingFileStream: scrie într-un fișier și se poate roti la un anumit timp
intervale.

· QueueStream: scrieți într-o coadă de memorie

· StdoutStream: scrie în stdout

· FancyStdoutStream: scrie ieșire colorată cu prefixe de timp în stdout

stdout_stream.*
Toate opțiunile începând cu stdout_stream. altele decât clasă va fi trecut de
constructor la crearea unei instanțe a clasei definite în
stdout_stream.class.

close_child_stdout
Dacă este setat la True, fluxul stdout al fiecărui proces va fi trimis la /dev/null
după furculiţă. Setarea implicită este False.

close_child_stderr
Dacă este setat la True, fluxul stderr al fiecărui proces va fi trimis la /dev/null
după furculiţă. Setarea implicită este False.

trimite_hup
Dacă este adevărat, o reîncărcare a procesului se va face prin trimiterea semnalului SIGHUP. Valori implicite
la Fals.

semnal_oprire
Semnalul de trimis la oprirea procesului. Poate fi specificat ca număr sau a
numele semnalului. Numele semnalelor nu fac distincție între majuscule și minuscule și pot include „SIG” sau nu. Asa de
exemple valide includ părăsi, INT, TERMEN ȚINTĂ și 3. Setarea implicită este SIGTERM.

stop_copii
La trimiterea semnal_oprire, trimiteți-o și copiilor. Implicit la
Fals.

max_retry
De câte ori încercăm să începem un proces, înainte să abandonăm și să ne oprim
întregul supraveghetor. Implicit la 5. Setați la -1 pentru a dezactiva max_retry și reîncercați
pe termen nelimitat.

graceful_timeout
Numărul de secunde de așteptat înainte ca un proces să se termine cu grație
ucidendu-l.

Când oprim un proces, îl trimitem mai întâi a semnal_oprire. Un muncitor poate prinde asta
semnal pentru a efectua operațiuni de curățare înainte de a ieși. Dacă muncitorul este nemișcat
activ după graceful_timeout secunde, îi trimitem un semnal SIGKILL. Nu este
este posibil să se prindă semnalele SIGKILL, astfel încât lucrătorul să se oprească.

Implicit la 30 de secunde.

prioritate
Număr întreg care definește o prioritate pentru observator. Când Arbitrul face ceva
operațiuni pe toți observatorii, îi va sorta cu acest câmp, din cel mai mare
număr la cel mai mic. Implicit la 0.

Singleton
Dacă este setat la True, acest observator va avea cel mult un proces. Implicit la
Fals.

use_sockets
Dacă este setat la True, acest observator va putea accesa socket-urile definite prin intermediul lor
descriptori de fișiere. Dacă este fals, toate fd-urile părinte sunt închise atunci când procesul copil este
bifurcat. Setarea implicită este False.

varsta_max
Dacă este setat, procesul va fi repornit cândva după max_age secunde. Acest
este util atunci când procesele se ocupă de un grup de conectori: repornirea proceselor
îmbunătățește echilibrarea sarcinii. Implicit, este dezactivat.

varianță_vârstă_max
Dacă este setat max_age, procesul va dura între max_age și max_age +
random(0, max_age_variance) secunde. Acest lucru evită repornirea tuturor proceselor pentru a
observator deodată. Implicit, 30 de secunde.

la cerere
Dacă este setat la True, procesele vor fi pornite numai după prima conexiune la
una dintre prizele configurate (vezi mai jos). Dacă este nevoie de o repornire, va fi
declanșat doar la următorul eveniment socket.

cârlige.*
Cârlige disponibile: înainte_începe, after_start, inainte de_aparitie, after_spawn,
înainte_stop, după_oprire, înainte_semnal, după_semnal, statistici_extinse

Definiți funcțiile de apel invers care se conectează la procesul de pornire/oprire a observatorului.

Dacă cârligul se întoarce Fals iar dacă cârligul este unul dintre înainte_începe, inainte de_aparitie,
after_start or after_spawn, pornirea va fi anulată.

Dacă cârligul este înainte_semnal și se întoarce Fals, apoi semnalul corespunzător
nu va fi trimis (cu excepția SIGKILL care este întotdeauna trimis)

Observați că un cârlig care eșuează în timpul procesului de oprire nu îl va anula.

Definiția de apel invers poate fi urmată de un steag boolean separat prin virgulă.
Când steagul este setat la adevărat, orice eroare care apare în cârlig va fi ignorată. Dacă
setat la fals (implicit), cârligul va reveni Fals.

Mai multe despre cârlige.

virtualenv
Când este furnizat, indică rădăcina unui director Virtualenv. Privitorul va face
scanează localul site-pachete și își încarcă conținutul în execuție
mediu inconjurator. Trebuie folosit cu copy_env setată la Adevărat. Implicit la Niciunul.

virtualenv_py_ver
Specifică versiunea python a virtualenv (de exemplu, „3.3”). Este util dacă
circ rulează cu o altă versiune python (de exemplu, „2.7”). Observatorul va scana
local site-pachete a versiunii Python specificate și încărcați conținutul acesteia în
mediul de execuție. Trebuie folosit cu virtualenv. Implicit la Niciunul.

respawn
Dacă este setat la Fals, procesele gestionate de un observator nu vor fi reapare
automat. Procesele pot fi respawnate manual cu ajutorul Începe comanda.
(implicit: adevărat)

use_papa
Setați la adevărat pentru a folosi papa.

priza:NAME - as multe secțiuni as tu vrea
gazdă Gazda prizei. Implicit la „localhost”

port Portul. Implicit la 8080.

familie Familia de prize. Poate fi „AF_UNIX”, „AF_INET” sau „AF_INET6”. Implicit la
„AF_INET”.

tip Tipul prizei. Poate fi „SOCK_STREAM”, „SOCK_DGRAM”, „SOCK_RAW”, „SOCK_RDM” sau
„SOCK_SEQPACKET”. Implicit, „SOCK_STREAM”.

interfață
Când este furnizat un nume de interfață de rețea, cum ar fi „eth0”, leagă socket-ul la acesta
anumit dispozitiv, astfel încât numai pachetele primite de la acea interfață anume
sunt procesate de socket. Aceasta poate fi folosită, de exemplu, pentru a limita dispozitivul
pentru a lega atunci când se leagă pe IN_ADDR_ANY (0.0.0.0) sau IN_ADDR_BROADCAST
(255.255.255.255). Rețineți că acest lucru funcționează numai pentru unele tipuri de prize, în special
Prize AF_INET.

cale Când este furnizată o cale către un fișier care va fi folosit ca fișier socket Unix. În cazul în care o
este furnizată calea, familie este forțat să AF_UNIX și gazdă și port sunt ignorate.

masca Când este furnizat, setează umask care va fi folosit pentru a crea un socket AF_UNIX. Pentru
exemplu, umask=000 va produce un socket cu permisiune 777.

înlocui
Când creați socket-uri Unix ("AF_UNIX"), un fișier existent poate indica o problemă
deci implicit este să eșueze. Specifica Adevărat pentru a elimina pur și simplu fișierul vechi, dacă sunteți
asigurați-vă că priza este administrată doar de Circus.

so_reuseport
Dacă este setat la Adevărat și SO_REUSEPORT este disponibil pe platforma țintă, circ o va face
creați și legați socket-uri SO_REUSEPORT noi pentru fiecare lucrător pe care îl pornește, care este a
utilizator al acestei prize.

use_papa
Setați la adevărat pentru a folosi papa.

Odată ce o priză este creată, ${circus.sockets.NAME} șir poate fi folosit în comandă
(cmd or args) al unui observator. Circul îl va înlocui cu valoarea FD. Privitorul trebuie, de asemenea
avea use_sockets setat la Adevărat altfel priza va fi fost închisă și veți obține
erori atunci când observatorul încearcă să-l folosească.

Exemplu:

[watcher:webworker]
cmd = chaussette --fd $(circus.sockets.webapp) chaussette.util.bench_app
use_sockets = Adevărat

[socket:webapp]
gazdă = 127.0.0.1
port = 8888

plugin:NAME - as multe secțiuni as tu vrea
utilizare Numele complet calificat care indică clasa de plugin.

nimic altfel
Orice altă cheie găsită în secțiune este transmisă constructorului pluginului din
config cartografiere.

Puteți utiliza toate opțiunile de urmărire, deoarece un plugin este pornit ca un observator.

Circus vine cu câteva plugin-uri pre-expediate, dar le puteți extinde cu ușurință
dezvoltandu-ti propriul tau.

env or env[:WATCHERS] - as multe secțiuni as tu vrea
nimic
Numele unei variabile de mediu căreia i se atribuie valoare. mediu în stil bash
substituțiile sunt acceptate. de exemplu, anexează / cos la PATH 'CALEA =
$PATH:/ cos'

Secțiune responsabilă cu livrarea variabilelor de mediu pentru a rula procesele.

Exemplu:

[watcher:worker1]
cmd = ping 127.0.0.1

[watcher:worker2]
cmd = ping 127.0.0.1

[env]
CAKE = minciuna

Variabila CAKE se va propaga tuturor observatorilor definiți în fișierul de configurare.

WATCHERS poate fi o listă separată prin virgulă de secțiuni de observator la care să se aplice acest mediu.
dacă mai multe secțiuni de mediu se potrivesc cu un observator, acestea vor fi combinate în ordinea în care apar
fisierul de configurare. intrările ulterioare vor avea prioritate.

Exemplu:

[watcher:worker1]
cmd = ping 127.0.0.1

[watcher:worker2]
cmd = ping 127.0.0.1

[env:worker1,worker2]
CALEA = / cos

[env:worker1]
PATH = $CALEA

[env:worker2]
CAKE = minciuna

muncitor1 va fi rulat cu PATH = $PATH (extins din mediul în care a fost rulat circusd)
muncitor2 va fi rulat cu PATH = / cos și CAKE = minciună

Este posibil să folosiți și metacaracterele.

Exemplu:

[watcher:worker1]
cmd = ping 127.0.0.1

[watcher:worker2]
cmd = ping 127.0.0.1

[env:lucrător*]
CALEA = / cos

Ambele muncitor1 și muncitor2 va fi rulat cu PATH = / cos

Utilizarea mediu inconjurator variabile
Când scrieți fișierul de configurare, puteți utiliza variabilele de mediu definite în env
secțiune sau în os.mediu însăși.

Trebuie doar să folosești circ.env. prefix.

Exemplu:

[watcher:worker1]
cmd = $(circus.env.shell)

[watcher:worker2]
baz = $(circus.env.user)
bar = $(circus.env.yeah)
sup = $(circus.env.oh)

[socket:socket1]
port = $(circus.env.port)

[plugin:plugin1]
foloseste = some.path
parametru1 = $(circus.env.plugin_param)

[env]
da = boo

[env:worker2]
oh = ok

Dacă o variabilă este definită în mai multe locuri, valoarea cea mai specializată are prioritate: a
variabilă definită în env:XXX va suprascrie o variabilă definită în env, care va trece peste a
variabilă definită în os.mediu.

substituțiile de mediu pot fi utilizate în orice secțiune a configurației din orice secțiune
variabilă.

Formatarea il comenzi și argumente cu dinamic variabile
După cum probabil ați văzut, este posibil să transmiteți unele informații care sunt calculate
dinamic la rularea proceselor. Printre altele, puteți obține ID-ul lucrătorului
(WID) și toate opțiunile care sunt trecute către Proces. În plus, este posibil să
accesați opțiunile transmise către Watcher care a instanciat procesul.

NOTĂ:
ID-ul lucrătorului este diferit de id-ul procesului. Este o valoare unică, începând cu 1,
care este unic doar pentru observator.

De exemplu, dacă doriți să accesați unele variabile care sunt conținute în mediu,
ar trebui să o faci cu o setare ca aceasta:

cmd = "fa-mi-o cafea --zahăr $(CIRCUS.ENV.SUGAR_AMOUNT)"

Acest lucru funcționează cu ambele cmd și args.

Important:

· Toate variabilele sunt prefixate cu circ.

· Înlocuirea nu face distincție între majuscule și minuscule.

Pârâu configuraţie
Clasă de flux simplă, cum ar fi QueueStream și StdoutStream nu au atribute specifice dar
o altă clasă de flux poate avea unele:

FileStream
nume de fișier
Calea fișierului în care va fi scris jurnalul.

format_timp
Formatul strftime care va fi folosit pentru a prefix de fiecare dată un marcaj de timp. De
implicit, acestea nu vor fi prefixate.

adică: %Y-%m-%d %H:%M:%S

max_bytes
Dimensiunea maximă a fișierului jurnal înainte de începerea unui fișier nou. Dacă nu este furnizat,
fișierul nu este inversat.

backup_count
Numărul de fișiere jurnal care vor fi păstrate În mod implicit backup_count este nul.

NOTĂ:
Rollover are loc ori de câte ori fișierul jurnal curent are lungimea de aproape max_bytes. Dacă
backup_count este >= 1, sistemul va crea succesiv fișiere noi cu aceleași
pathname ca fișier de bază, dar cu extensiile „.1”, „.2” etc. Pentru
de exemplu, cu un backup_count de 5 și un nume de fișier de bază „app.log”, veți obține
„app.log”, „app.log.1”, „app.log.2”, ... până la „app.log.5”. Fișierul se scrie
to este întotdeauna „app.log” - când se umple, este închis și redenumit în
„app.log.1”, iar dacă există fișiere „app.log.1”, „app.log.2” etc., atunci acestea sunt redenumite
la „app.log.2”, respectiv „app.log.3” etc.

Exemplu:

[watcher:myprogram]
cmd = python -m myapp.server

stdout_stream.class = FileStream
stdout_stream.filename = test.log
stdout_stream.time_format = %Y-%m-%d %H:%M:%S
stdout_stream.max_bytes = 1073741824
stdout_stream.backup_count = 5

VizionatFileStream
nume de fișier
Calea fișierului în care va fi scris jurnalul.

format_timp
Formatul strftime care va fi folosit pentru a prefix de fiecare dată un marcaj de timp. De
implicit, acestea nu vor fi prefixate.

adică: %Y-%m-%d %H:%M:%S

NOTĂ:
WatchedFileStream se bazează pe un instrument extern de rotație a jurnalelor pentru a se asigura că fișierele jurnal
nu devii prea mare. Fișierul de ieșire va fi monitorizat și dacă va fi șters vreodată sau
mutat de instrumentul extern de rotație a jurnalului, atunci mânerul fișierului de ieșire va fi
reîncărcat automat.

Exemplu:

[watcher:myprogram]
cmd = python -m myapp.server

stdout_stream.class = WatchedFileStream
stdout_stream.filename = test.log
stdout_stream.time_format = %Y-%m-%d %H:%M:%S

TimedRotatingFileStream
nume de fișier
Calea fișierului în care va fi scris jurnalul.

backup_count
Numărul de fișiere jurnal care vor fi păstrate În mod implicit backup_count este nul.

format_timp
Formatul strftime care va fi folosit pentru a prefix de fiecare dată un marcaj de timp. De
implicit, acestea nu vor fi prefixate.

adică: %Y-%m-%d %H:%M:%S

rotiți_când
Tipul de interval. Lista de valori posibile este mai jos. Rețineți că sunt
nu disting majuscule.

┌───────────┬─────────────────────────
│Valoare │ Tip de interval │
├───────────┼────────────────────────────
│'S' │ Secunde │
├───────────┼────────────────────────────
│'M' │ Minute │
├───────────┼────────────────────────────
│'H' │ Ore │
├───────────┼────────────────────────────
│'D' │ Zile │
├───────────┼────────────────────────────
│'W0'-'W6' │ Ziua săptămânii (0=luni) │
├───────────┼────────────────────────────
│'miezul nopții' │ Se răstoarnă la miezul nopții │
└───────────┴─────────────────────────

interval_rotire
Intervalul de rulare.

NOTĂ:
TimedRotatingFileStream rotește fișierele jurnal la anumite intervale de timp. Interval de rulare
este determinată de o combinație de rotate_when și rotate_interval.

Exemplu:

[watcher:myprogram]
cmd = python -m myapp.server

stdout_stream.class = TimedRotatingFileStream
stdout_stream.filename = test.log
stdout_stream.time_format = %Y-%m-%d %H:%M:%S
stdout_stream.utc = Adevărat
stdout_stream.rotate_when = H
stdout_stream.rotate_interval = 1

FancyStdoutStream
culoare

nume of an ascii culoare:

· roșu

· verde

· galben

· albastru

· magenta

· cyan

· alb

format_timp
Formatul strftime cu care va fi prefixat fiecare linie.

Implicit la: %Y-%m-%d %H:%M:%S

Exemplu:

[watcher:myprogram]
cmd = python -m myapp.server
stdout_stream.class = FancyStdoutStream
stdout_stream.color = verde
stdout_stream.time_format = %Y/%m/%d | %H:%M:%S

Comenzi
În epicentrul circului trăiesc sistemele de comandă. circ este doar un client zeromq,
iar dacă este necesar, puteți conduce programatic sistemul Circus scriind propriul zmq
de client.

Toate mesajele sunt mapări JSON.

Pentru fiecare comandă de mai jos, oferim un exemplu de utilizare cu circusctl dar și intrarea /
trimite mesaje zmq.

circ-ctl comenzi
· adăuga: comenzi/adăugați

· decr: comenzi/decr

· dstats: comenzi/dstats

· obține: comenzi/get

· opțiuni globale: comenzi/opțiuni globale

· incr: comenzi/incr

· piton: comenzi/ipython

· listă: comenzi/listă

· asculta: comenzi/ascultă

· listsocket-uri: comenzi/listsocket-uri

· numprocese: comenzi/numprocese

· numwatchers: comenzi/numwatchers

· Opțiuni: comenzi/opțiuni

· părăsi: comenzi/ieșire

· reincarca: comenzi/reîncărcare

· reloadconfig: comenzi/reloadconfig

· reîncepe: comenzi/repornire

· rm: comenzi/rm

· set: comenzi/set

· semnal: comenzi/semnal

· Începe: comenzi/pornire

· Statistici: comenzi/statistici

· Starea: comenzi/stare

· opri: comenzi/oprire

Adăuga a Watcher
Această comandă adaugă dinamic un observator la un arbitru.

ZMQ Mesaj
{
"comanda": "adăugați",
„proprietăți”: {
"cmd": "/cale/la/linie de comandă --opțiune"
"nume": "numele observatorului"
„args”: [],
"Opțiuni": {},
„începe”: fals
}
}

Un mesaj conține 2 proprietăți:

· cmd: linie de comandă completă de executat într-un proces

· args: matrice, argumente transmise comenzii (opțional)

· nume: numele observatorului

· opțiuni: opțiuni ale unui observator

· start: porniți observatorul după creare

Răspunsul returnează starea „ok”.

Comandă linie
$ circusctl adauga [--start]

Opţiuni
· : numele observatorului de creat

· : linie de comandă completă de executat într-un proces

· --start: porniți imediat observatorul

Decrementați il număr of procese in a Watcher
Acest comentariu reduce numărul de procese dintr-un observator cu , 1 fiind cel
Mod implicit.

ZMQ Mesaj
{
"comandă": "decr",
„proprietăți”: {
"Nume": " "
„nb”:
„așteaptă”: fals
}
}

Răspunsul returnează numărul de procese din proprietatea „numprocesses”:

{ "status": "ok", "numprocesses": , „ora”, „stampă de timp” }

Comandă linie
$ circusctl decr [ ] [--așteaptă]

Opţiuni
· : numele observatorului

· : numărul de procese de eliminat.

Obține circ Statistici
Puteți obține oricând niște statistici despre circusd cu comanda dstat.

ZMQ Mesaj
Pentru a obține statisticile circului, pur și simplu rulați:

{
"comandă": "dstats"
}

Răspunsul returnează o mapare a proprietății „infos” care conține câteva informații despre proces:

{
„informații”: {
„copii”: [],
"cmdline": "python",
"cpu": 0.1,
"ctime": "0:00.41",
„mem”: 0.1,
"mem_info1": "3M",
"mem_info2": "2G",
"frumos": 0,
„pid”: 47864,
„nume utilizator”: „rădăcină”
},
"status": "ok",
„timp”: 1332265655.897085
}

Comandă Linie
$ circusctl dstats

Obține il valoare of specific Watcher Opțiuni
Această comandă poate fi folosită pentru a interoga valoarea curentă a uneia sau mai multor opțiuni de observator.

ZMQ Mesaj
{
"comandă": "obține",
„proprietăți”: {
"keys": ["key1, "key2"]
"nume": "numele observatorului"
}
}

Un mesaj de solicitare conține două proprietăți:

· chei: listă, cheile de opțiune pentru care doriți să obțineți valorile

· nume: numele observatorului

Obiectul răspuns are o proprietate Opțiuni care este un dicționar de nume de opțiuni și
valori.

de exemplu:

{
"status": "ok",
"Opțiuni": {
"graceful_timeout": 300,
"send_hup": Adevărat,
},
ora': 1332202594.754644
}

Comandă linie
$ circusctl obţine

Obține il arbitru Opțiuni
Această comandă returnează opțiunile arbitrului

ZMQ Mesaj
{
"comandă": "opțiuni globale",
„proprietăți”: {
"key1": "val1",
..
}
}

Un mesaj conține 2 proprietăți:

· chei: listă, cheile de opțiune pentru care doriți să obțineți valorile

Răspunsul returnează un obiect cu o proprietate „opțiuni” care conține lista cheie/valoare
întors de circ.

de exemplu:

{
"status": "ok",
"Opțiuni": {
„check_delay”: 1,
...
},
ora': 1332202594.754644
}

Comandă linie
$ circusctl globaloptions

Opţiuni
Cheile de opțiuni sunt:

· punct final: punctul final al controlerului ZMQ

· pubsub_endpoint: punctul final pubsub

· check_delay: întârzierea dintre două puncte de control

· multicast_endpoint: punctul final de multicast pentru descoperirea automată a clusterului de circ

Creştere il număr of procese in a Watcher
Acest comentariu crește numărul de procese dintr-un observator cu , 1 fiind cel
lipsă

ZMQ Mesaj
{
"comandă": "incr",
„proprietăți”: {
"Nume": " ",
„nb”: ,
„așteaptă”: fals
}
}

Răspunsul returnează numărul de procese din proprietatea „numprocesses”:

{ "status": "ok", "numprocesses": , „ora”, „stampă de timp” }

Comandă linie
$ circusctl incr [ ] [--așteaptă]

Opţiuni
· : numele observatorului.

· : numărul de procese de adăugat.

Crea coajă în circ proces
Această comandă este utilă numai dacă aveți pachetul ipython instalat.

Comandă Linie
$ circusctl ipython

Obține listă of observatorii or procese in a Watcher
ZMQ Mesaj
Pentru a obține lista tuturor observatorilor:

{
"comandă": "listă",
}

Pentru a obține lista proceselor active într-un observator:

{
"comandă": "listă",
„proprietăți”: {
"nume": "numele observatorului",
}
}

Răspunsul returnează lista cerută. cartografierea returnată poate fi fie „observatori” fie
'pids' in functie de solicitare.

Comandă linie
$ circusctl list [ ]

Mă abonez la a Watcher eveniment
ZMQ
În orice moment vă puteți abona la un eveniment de circ. Circus oferă un flux PUB/SUB pe care
orice client se poate abona. URI-ul punctului final de abonat este setat în circus.ini
Fișier de configurare.

Evenimentele sunt subiecte pubsub:

· privitor. .culege: când se recoltează un proces

· privitor. .icre: când un proces este generat

· privitor. .ucide: când un proces este ucis

· privitor. .actualizat: când configurația Watcher este actualizată

· privitor. .Stop: când un observator este oprit

· privitor. .start: când este pornit un observator

Toate mesajele de evenimente sunt într-o structură json.

Comandă linie
Clientul a fost actualizat pentru a oferi o modalitate simplă de a asculta evenimentele:

ascultă circ [ , ...]

Exemplu of rezultat:
$ circusctl asculta tcp://127.0.0.1:5556
watcher.refuge.spawn: {u'process_id': 6, u'process_pid': 72976,
timpul tău: 1331681080.985104}
watcher.refuge.spawn: {u'process_id': 7, u'process_pid': 72995,
timpul tău: 1331681086.208542}
watcher.refuge.spawn: {u'process_id': 8, u'process_pid': 73014,
timpul tău: 1331681091.427005}

Obține il listă of prize
ZMQ Mesaj
Pentru a obține lista de prize:

{
"comandă": "listsockets",
}

Răspunsul returnează o listă de mapări json cu chei pentru fd, nume, gazdă și port.

Comandă linie
$ circusctl listsockets

Obține il număr of procese
Obțineți numărul de procese într-un observator sau într-un arbitru

ZMQ Mesaj
{
"comandă": "numproceses",
„proprietăți”: {
"Nume": " "
}

}

Răspunsul returnează numărul de procese din proprietatea „numprocesses”:

{ "status": "ok", "numprocesses": , „ora”, „stampă de timp” }

Dacă numele proprietății nu este specificat, se returnează suma tuturor proceselor gestionate.

Comandă linie
$ circusctl numproceses [ ]

Opţiuni
· : numele observatorului

Obține il număr of observatorii
Obțineți numărul de observatori într-un arbitru

ZMQ Mesaj
{
"command": "numwatchers",
}

Răspunsul returnează numărul de observatori din proprietatea „numwatchers”:

{ "status": "ok", "numwatchers": , „ora”, „stampă de timp” }

Comandă linie
$ circusctl numwatchers

Obține il valoare of toate Opțiuni pentru a Watcher
Această comandă returnează toate valorile opțiunilor pentru un observator dat.

ZMQ Mesaj
{
"comandă": "opțiuni",
„proprietăți”: {
"nume": "numele observatorului",
}
}

Un mesaj conține 1 proprietate:

· nume: numele observatorului

Obiectul răspuns are o proprietate Opțiuni care este un dicționar de nume de opțiuni și
valori.

de exemplu:

{
"status": "ok",
"Opțiuni": {
"graceful_timeout": 300,
"send_hup": Adevărat,
...
},
ora': 1332202594.754644
}

Comandă linie
$ opțiuni de circ

Opţiuni
· : numele observatorului

Cheile de opțiuni sunt:

· numproceses: întreg, număr de procese

· warmup_delay: număr întreg sau număr, întârziere de așteptare între apariția procesului în secunde

· working_dir: șir, directorul în care va fi executat procesul

· uid: șir sau întreg, ID utilizator utilizat pentru lansarea procesului

· gid: șir sau întreg, ID de grup folosit pentru a lansa procesul

· send_hup: boolean, dacă TRU semnalul HUP va fi folosit la reîncărcare

· shell: boolean, va rula comanda în mediul shell dacă este adevărat

· cmd: șir, linia de comandă folosită pentru lansarea procesului

· env: obiect, definește mediul în care va fi lansat procesul

· retry_in: întreg sau număr, timpul în secunde pe care îl așteptăm înainte de a reîncerca să lansăm
proces dacă a fost atins numărul maxim de încercări.

· max_retry: întreg, numărul maxim de bucle de reîncercări

· graceful_timeout: întreg sau număr, timp în care așteptăm înainte să omorâm cu siguranță un proces.

· prioritate: folosit pentru a sorta observatorii în arbitru

· singleton: dacă este adevărat, un observator singleton.

· max_age: timpul pe care un proces poate trăi înainte de a fi repornit

· max_age_variance: durata suplimentară variabilă de trăit, evită turmarea în ștampilare.

Părăsi il arbitru imediat
Când arbitrul primește această comandă, arbitrul iese.

ZMQ Mesaj
{
"comandă": "Închide",
„așteaptă”: fals
}

Răspunsul returnează starea „ok”.

If aşteptare este Fals (implicit), apelul va reveni imediat după apel semnal_oprire
pe fiecare proces.

If aşteptare este adevărat, apelul va reveni numai când procesul de oprire este complet încheiat.
Din cauza opțiunii graceful_timeout, poate dura ceva timp.

Comandă linie
$ circusctl ieși [--așteaptă]

reload il arbitru or a Watcher
Această comandă reîncarcă tot procesul dintr-un observator sau toți observatorii. Acest lucru se va întâmpla într-una
din 3 moduri:

· Dacă grațios este fals, are loc o repornire simplă.

· Dacă trimite_hup este adevărat pentru observator, un semnal HUP este trimis fiecărui proces.

·

In caz contrar:

· Dacă secvenţial este fals, arbitrul va încerca să apară numprocese nou
proceselor. Dacă noile procese sunt generate cu succes, rezultatul este că
toate procesele vechi sunt oprite, deoarece implicit cele mai vechi procese sunt
oprit atunci când numărul real de procese pentru un observator este mai mare decât
numprocese.

· Dacă secvenţial este adevărat, arbitrul va reporni fiecare proces într-o secvenţă
cale (cu a întârziere_încălzire pauză între fiecare pas)

ZMQ Mesaj
{
"comandă": "reîncărcare",
„proprietăți”: {
"Nume": ' ",
„grațios”: adevărat,
„secvențial”: fals,
„așteaptă”: fals
}
}

Răspunsul returnează starea „ok”. Dacă proprietatea graceful este setată la true, procesele
va fi ieșit grațios.

Dacă numele proprietății este prezent, atunci reîncărcarea va fi aplicată observatorului.

Comandă linie
$ reîncărcare circ [ ] [--terminate] [--waiting]
[--secvential]

Opţiuni
· : numele observatorului

· --termină; părăsiți imediat nodul

reload il configuraţie fişier
Această comandă reîncarcă fișierul de configurare, așa că vor fi modificări în fișierul de configurare
reflectată în configuraţia circului.

ZMQ Mesaj
{
"comanda": "reloadconfig",
„așteaptă”: fals
}

Răspunsul returnează starea „ok”. Dacă proprietatea graceful este setată la true, procesele
va fi ieșit grațios.

Comandă linie
$ circusctl reloadconfig [--așteaptă]

Repornire il arbitru or a Watcher
Această comandă repornește tot procesul într-un observator sau toți observatorii. Această funcție pur și simplu
opriți un observator, apoi reporniți-l.

ZMQ Mesaj
{
"comandă": "reporniți",
„proprietăți”: {
"Nume": " ",
„în așteptare”: fals,
„match”: „[simple|glob|regex]”
}
}

Răspunsul returnează starea „ok”.

Dacă numele proprietății este prezent, atunci reîncărcarea va fi aplicată observatorului.

If aşteptare este Fals (implicit), apelul va reveni imediat după apel semnal_oprire
pe fiecare proces.

If aşteptare este adevărat, apelul va reveni numai când procesul de repornire este complet
încheiat. Din cauza opțiunii graceful_timeout, poate dura ceva timp.

Meci parametrul poate avea valoarea simplu pentru compararea șirurilor, glob pentru wildcard
potrivire (implicit) sau regex pentru potrivirea regex.

Comandă linie
$ circusctl restart [nume] [--waiting] [--match=simple|glob|regex]

Opţiuni
· : numele sau modelul observatorului(lor)

· : metoda de potrivire a observatorului

Elimină a Watcher
Această comandă elimină în mod dinamic un observator din arbitru. Privitorii sunt cu grație
oprit implicit.

ZMQ Mesaj
{
"comandă": "rm",
„proprietăți”: {
"Nume": " ",
„nostop”: fals,
„așteaptă”: fals
}
}

Răspunsul returnează starea „ok”.

If fara oprire este Adevărat (implicit: Fals), procesele pentru observator nu vor fi oprite -
în schimb, observatorul va fi doar uitat de circ și procesele observatorului vor fi
responsabili pentru oprirea lor. Dacă fara oprire nu este specificat sau este fals, atunci
procesele observatorului vor fi oprite cu grație.

If aşteptare este Fals (implicit), apelul va reveni imediat după ce începe eliminarea
și opriți observatorul corespunzător.

If aşteptare este adevărat, apelul va reveni numai atunci când procesul de eliminare și oprire este
complet încheiată. Din cauza opțiunii graceful_timeout, poate dura ceva timp.

Comandă linie
$ circusctl rm [--așteaptă] [--nostop]

Opţiuni
· : numele observatorului de eliminat

· nostop: nu opriți procesele de urmărire, doar eliminați observatorul

set a Watcher opțiune
ZMQ Mesaj
{
"comandă": "setează",
„proprietăți”: {
"nume": "numele observatorului",
"Opțiuni": {
"key1": "val1",
..
}
„așteaptă”: fals
}
}

Răspunsul returnează starea „ok”. Consultați comanda Opțiuni pentru o listă de taste de setat.

Comandă linie
$ circusctl set --aşteptare

Trimiteți a semnal
Această comandă vă permite să trimiteți un semnal către toate procesele dintr-un monitor, un anumit proces
într-un observator sau copiii săi.

ZMQ Mesaj
Pentru a trimite un semnal către toate procesele pentru un observator:

{
"comandă": "semnal",
„proprietate”: {
"Nume": ,
„signum”:
}

Pentru a trimite un semnal unui proces:

{
"comandă": "semnal",
„proprietate”: {
"Nume": ,
"pid": ,
„signum”:
}

O proprietate opțională „copii” poate fi folosită mai degrabă pentru a trimite semnalul tuturor copiilor
decât procesul în sine:

{
"comandă": "semnal",
„proprietate”: {
"Nume": ,
"pid": ,
"signum": ,
„copii”: Adevărat
}

Pentru a trimite un semnal unui copil de proces:

{
"comandă": "semnal",
„proprietate”: {
"Nume": ,
"pid": ,
"signum": ,
„child_pid”: ,
}

De asemenea, este posibil să trimiteți un semnal tuturor copiilor observatorului:

{
"comandă": "semnal",
„proprietate”: {
"Nume": ,
"signum": ,
„copii”: Adevărat
}

În cele din urmă, puteți trimite un semnal procesului și copiii săi, cu recursiv opţiune:

{
"comandă": "semnal",
„proprietate”: {
"Nume": ,
"signum": ,
„recursiv”: Adevărat
}

Comandă linie
$ semnal circ [ ] [--copii]
[--recursiv]

Opțiuni:
· : numele observatorului

· : întreg, id-ul procesului.

· : numărul semnalului (sau numele) de trimis.

· : pid-ul unui copil, dacă este cazul

· : boolean, trimite semnalul tuturor copiilor

· : boolean, trimite semnalul procesului și copiilor acestuia

acasă il arbitru or a Watcher
Această comandă pornește toate procesele dintr-un observator sau toți observatorii.

ZMQ Mesaj
{
"comandă": "pornire",
„proprietăți”: {
"Nume": ' ",
„în așteptare”: fals,
„match”: „[simple|glob|regex]”
}
}

Răspunsul returnează starea „ok”.

Dacă numele proprietății este prezent, observatorul va fi pornit.

If aşteptare este Fals (implicit), apelul va reveni imediat după apel Începe on
fiecare proces.

If aşteptare este adevărat, apelul va reveni numai când procesul de pornire este complet încheiat.
Din cauza opțiunii graceful_timeout, poate dura ceva timp.

Meci parametrul poate avea valoarea simplu pentru compararea șirurilor, glob pentru wildcard
potrivire (implicit) sau regex pentru potrivirea regex.

Comandă linie
$ circusctl restart [nume] [--waiting] [--match=simple|glob|regex]

Opţiuni
· : numele sau modelul observatorului(lor)

· : metoda de potrivire a observatorului

Obține proces informații
Puteți obține în orice moment câteva statistici despre procesele dvs. cu comanda stat.

ZMQ Mesaj
Pentru a obține statistici pentru toți observatorii:

{
"comandă": "statistici"
}

Pentru a obține statistici pentru un observator:

{
"comandă": "statistici",
„proprietăți”: {
"Nume":
}
}

Pentru a obține statistici pentru un proces:

{
"comandă": "statistici",
„proprietăți”: {
"Nume": ,
"proces":
}
}

Statisticile pot fi extinse cu cârligul extended_stats, dar statisticile extinse trebuie să fie
solicitat:

{
"comandă": "statistici",
„proprietăți”: {
"Nume": ,
"proces": ,
„extins”: Adevărat
}
}

Răspunsul returnează un obiect per proces cu proprietatea „info” care conține un anumit proces
informatii:

{
„informații”: {
„copii”: [],
"cmdline": "python",
"cpu": 0.1,
"ctime": "0:00.41",
„mem”: 0.1,
"mem_info1": "3M",
"mem_info2": "2G",
"frumos": 0,
„pid”: 47864,
„nume utilizator”: „rădăcină”
},
„proces”: 5,
"status": "ok",
„timp”: 1332265655.897085
}

Comandă Linie
$ circusctl stats [--extended] [ ] [ ]

Obține il Starea of a Watcher or toate observatorii
Această comandă începe obține statutul unui observator sau al tuturor observatorilor.

ZMQ Mesaj
{
"comandă": "stare",
„proprietăți”: {
"Nume": ' ",
}
}

Răspunsul returnează starea „activ” sau „oprit” sau starea/observatorii.

Comandă linie
$ circusctl status [ ]

Opţiuni
· : numele observatorului

Exemplu
$ circusctl manechin de stare
activ
$ stare circ
manechin: activ
dummy2: activ
refugiu: activ

Stop observatorii
Această comandă oprește un observator dat sau toți observatorii.

ZMQ Mesaj
{
"comandă": "opriți",
„proprietăți”: {
"Nume": " ",
„în așteptare”: fals,
„match”: „[simple|glob|regex]”
}
}

Răspunsul returnează starea „ok”.

În cazul în care nume proprietatea este prezentă, atunci oprirea va fi aplicată observatorului
corespunzătoare numelui respectiv. În caz contrar, toți observatorii vor fi opriți.

If aşteptare este Fals (implicit), apelul va reveni imediat după apel semnal_oprire
pe fiecare proces.

If aşteptare este adevărat, apelul va reveni numai când procesul de oprire este complet încheiat.
Din cauza opțiunii graceful_timeout, poate dura ceva timp.

Meci parametrul poate avea valoarea simplu pentru compararea șirurilor, glob pentru wildcard
potrivire (implicit) sau regex pentru potrivirea regex.

Comandă linie
$ circusctl stop [nume] [--waiting] [--match=simple|glob|regex]

Opţiuni
· : numele sau modelul observatorului(lor)

· : metoda de potrivire a observatorului

CLI Unelte
blatul de circ
blatul de circ este o consolă de top pe care o poți rula pentru a urmări în direct sistemul tău Circus. Aceasta
va afișa CPU, utilizarea memoriei și accesările socket-ului dacă aveți unele.

Exemplu de ieșire:

-------------------------------------------------- ---------------------
circ-stats
CPU PID (%) MEMORIE (%)
14252 0.8 0.4
0.8 (medie) 0.4 (suma)

fals
CPU PID (%) MEMORIE (%)
14257 78.6 0.1
14256 76.6 0.1
14258 74.3 0.1
14260 71.4 0.1
14259 70.7 0.1
74.32 (medie) 0.5 (suma)

-------------------------------------------------- --------------------

blatul de circ este o consolă numai pentru citire. Dacă doriți să interacționați cu sistemul, utilizați circ.

circ
circ poate fi folosit pentru a rula orice comandă listată în comenzi. De exemplu, puteți obține un
o listă cu toți observatorii, puteți face

$ lista de circ

Pe lângă suportul pentru câteva opțiuni, puteți specifica și punctul final circ
utilizați folosind CIRCUSCTL_ENDPOINT variabilă de mediu.

web Consoleze
Circus vine cu o consolă web care poate fi utilizată pentru a gestiona sistemul.

Consola web vă permite:

· Conectați-vă la orice sistem Circus care rulează

· Urmăriți procesele CPU și utilizarea memoriei în timp real

· Adăugați sau omorâți procese

· Adăugați observatori noi

NOTĂ:
Funcția de utilizare a CPU și a memoriei în timp real folosește soclul pentru statistici. Dacă doriți să
activează-l, asigură-te că sistemul Circus la care te vei conecta are statisticile îndreptate
activat în configurația sa:

[circ]
statsd = Adevărat

În mod implicit, această opțiune nu este activată.

Consola web este propriul pachet, trebuie să instalați:

$ pip install circ-web

Pentru a activa consola, adăugați câteva opțiuni în fișierul Circus ini:

[circ]
httpd = Adevărat
httpd_host = gazdă locală
httpd_port = 8080

httpd_host și httpd_port sunt opționale și implicit localhost și 8080.

Dacă doriți să rulați aplicația web pe cont propriu, rulați doar aplicația circhttpd scenariu:

$ circhttpd
Se pornește serverul de sticle...
Ascultând mai departe http://localhost: 8080 /
Apăsați Ctrl-C pentru a ieși.

În mod implicit, scriptul va rula Consola Web pe portul 8080, dar opțiunea --port poate fi
folosit pentru a-l schimba.

Utilizarea il consolă
Odată ce scriptul rulează, puteți deschide un browser și vizitați http://localhost: 8080. Tu
ar trebui să primească acest ecran: [image]

Consola Web este pregătită pentru a fi conectată la un sistem Circus, având în vedere acesta punct final. De
implicit este punctul final tcp://127.0.0.1:5555.

Odată ce ai lovit Conectați, aplicația web se va conecta la sistemul Circus.

Cu Consola Web conectată, ar trebui să obțineți o listă de observatori și o stare în timp real
dintre cele două procese de Circ (circusd și circusd-stats).

Puteți face clic pe starea fiecărui observator pentru a o comuta Activ (verde) la Inactiv
(roșu). Această schimbare este efectivă imediat și vă permite să începeți și să opriți observatorii.

Dacă faceți clic pe numele observatorului, veți obține o pagină web pentru acel observator,
cu procesele sale:

Pe acest ecran, puteți adăuga sau elimina procese și le puteți ucide pe cele existente.

Nu în ultimul rând, puteți adăuga un observator nou-nouț făcând clic pe Adăuga Watcher conectați în
meniul din stânga: .SS alergând în spatele lui Nginx

Nginx poate acționa ca un proxy și un strat de securitate în fața circus-web.

NOTĂ:
Pentru a primi actualizări de stare și grafice în timp real în circus-web, trebuie să furnizați un Nginx
soluție proxy care are suport pentru websocket

nginx >= 1.3.13
Începând cu Nginx>=1.3.13, suportul pentru websocket este încorporat, deci nu este nevoie să combinați Nginx
cu Lac sau HAProxy. Un exemplu de configurare Nginx cu suport websocket:

în amonte circusweb_server {
server 127.0.0.1:8080;
}

Server {
asculta 80;
numele serverului _;

Locație / {
proxy_pass http://circusweb_server;
proxy_http_versiunea 1.1;
proxy_set_header Actualizare $http_upgrade;
proxy_set_header Conexiune „upgrade”;
proxy_set_header Gazdă $gazdă;
proxy_set_header X-Real-IP $adresă_la distanță;
proxy_set_header X-Forwarded-Pentru $ proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_redirect dezactivat;
}

locaţie ~/media/\*(.png|.jpg|.css|.js|.ico)$ {
alias /path_to_site-packages/circusweb/media/;
}
}

nginx < 1.3.13
Versiunile Nginx < 1.3.13 nu au suport pentru websocket încorporat.

Pentru a oferi suport websocket pentru circus-web atunci când utilizați Nginx < 1.3.13, puteți combina
Nginx cu Varnish sau HAProxy. Adica Nginx in fata circ-web, cu Varnish sau
HAProxy în fața lui Nginx.

Exemplul de mai jos arată configurația combinată Nginix și Varnish necesară pentru proxy
circ-web și oferă suport pentru websocket.

nginx configurare:

în amonte circusweb_server {
server 127.0.0.1:8080;
}

Server {
asculta 8001;
numele serverului _;

Locație / {
proxy_set_header X-Forwarded-Pentru $ proxy_add_x_forwarded_for;
proxy_set_header Gazdă $http_host;
proxy_redirect dezactivat;
proxy_pass http://circusweb_server;
}

locaţie ~/media/\*(.png|.jpg|.css|.js|.ico)$ {
alias /path_to_site-packages/circusweb/media/;
}
}

Dacă doriți mai multe opțiuni de configurare Nginx, consultați http://wiki.nginx.org/HttpProxyModule.

lac configurare:

backend implicit {
.host = "127.0.0.1";
.port = "8001";
}

priză backend {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 1s;
.first_byte_timeout = 2s;
.between_bytes_timeout = 60s;
}

sub vcl_pipe {
dacă (req.http.upgrade) {
set bereq.http.upgrade = req.http.upgrade;
}
}

sub vcl_recv {
dacă (req.http.Upgrade ~ "(?i)websocket") {
set req.backend = priză;
retur (conducta);
}
}

In the Varnish configuration example above two backends are defined. One serving the web
console and one serving the socket connections. Web console requests are bound to port
8001. The Nginx 'server' directive should be configured to listen on port 8001.

Websocket connections are upgraded and piped directly to the circushttpd process listening
on port 8080 by Varnish. i.e. bypassing the Nginx proxy.

Ubuntu
Since the version 13.10 (Cochet), Ubuntu includes Nginx with websocket support in its own
repositories. For older versions, you can install Nginx>=1.3.13 from the official Nginx
stable PPA, as so:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get instala nginx
nginx -v

Password-protect circhttpd
As explained in the Security page, running circhttpd is pretty unsafe. We don't provide
any security in Circus itself, but you can protect your console at the NGinx level, by
folosind http://wiki.nginx.org/HttpAuthBasicModule

Exemplu:

Locație / {
proxy_set_header X-Forwarded-Pentru $ proxy_add_x_forwarded_for;
proxy_set_header Gazdă $http_host;
proxy_set_header X-Forwarded-Host: $http_host;
proxy_set_header X-Forwarded-Proto: $scheme;
proxy_redirect dezactivat;
proxy_pass http://127.0.0.1: 8080;
auth_basic "Restricted";
auth_basic_user_file /path/to/htpasswd;
}

htpasswd file contains users and their passwords, and a password prompt will pop when
you access the console.

You can use Apache's htpasswd script to edit it, or the Python script they provide at:
http://trac.edgewall.org/browser/trunk/contrib/htpasswd.py

However, there's no native support for the combined use of HTTP Authentication and
WebSockets (the server will throw HTTP 401 error codes). A workaround is to disable such
authentication for the socket.io server.

Example (needs to be added before the previous rule):

location /socket.io {
proxy_set_header X-Forwarded-Pentru $ proxy_add_x_forwarded_for;
proxy_set_header Gazdă $http_host;
proxy_set_header X-Forwarded-Host: $http_host;
proxy_set_header X-Forwarded-Proto: $scheme;
proxy_redirect dezactivat;
proxy_pass http://127.0.0.1: 8080;
}

Of course that's just one way to protect your web console, you could use many other
tehnici.

Extinderea il web consolă
Am ales sticlă to build the webconsole, mainly because it's a really tiny framework that
doesn't do much. By having a look at the code of the web console, you'll eventually find
out that it's really simple to understand.

Here is how it's split:

· circushttpd.py file contains the "views" definitions and some code to handle the
socket connection (via socketio).

· cel controller.py contains a single class which is in charge of doing the communication
with the circus controller. It allows to have a nicer high level API when defining the
server web.

If you want to add a feature in the web console you can reuse the code that's existing. A
few tools are at your disposal to ease the process:

· Este un șablon de randare function, which takes the named arguments you pass to it and
pass them to the template renderer and return the resulting HTML. It also passes some
additional variables, such as the session, the circus version and the client if defined.

· If you want to run commands and doa redirection depending the result of it, you can use
il executa comanda function, which takes a callable as a first argument, a message in case
of success and a redirection url.

StatsNamespace class is responsible for managing the websocket communication on the
server side. Its documentation should help you to understand what it does.

De lucru cu prize
Circus can bind network sockets and manage them as it does for processes.

The main idea is that a child process that's created by Circus to run one of the watcher's
command can inherit from all the opened file descriptors.

That's how Apache or Unicorn works, and many other tools out there.

Scop
The goal of having sockets managed by Circus is to be able to manage network applications
in Circus exactly like other applications.

For example, if you use Circus with chaussette -- a WGSI server, you can get a very fast
web server running and manage "Web Workers" in Circus as you would do for any other
proces.

Splitting the socket managment from the network application itself offers a lot of
opportunities to scale and manage your stack.

Amenajări
The gist of the feature is done by binding the socket and start listening to it in
circ:

soclu de import

sock = socket.socket(FAMILY, TYPE)
sock.bind((HOST, PORT))
sock.listen(BACKLOG)
fd = sock.fileno()

Circus then keeps track of all the opened fds, and let the processes it runs as children
have access to them if they want.

If you create a small Python network script that you intend to run in Circus, it could
arata asa:

soclu de import
import sys

fd = int(sys.argv[1]) # getting the FD from circus
sock = socket.fromfd(fd, FAMILY, TYPE)

# dealing with one request at a time
pe când True:
conn, addr = sock.accept()
request = conn.recv(1024)
.. do something ..
conn.sendall(response)
conn.close()

Then Circus could run like this:

[circ]
check_delay = 5
punct final = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557

[watcher:dummy]
cmd = mycoolscript $(circus.sockets.foo)
use_sockets = Adevărat
întârziere_încălzire = 0
numprocese = 5

[socket:foo]
gazdă = 127.0.0.1
port = 8888

$(circus.sockets.foo) will be replaced by the FD value once the socket is created and
bound on the 8888 port.

NOTĂ:
Starting at Circus 0.8 there's an alternate syntax to avoid some conflicts with some
config parsers. You can write:

((circus.sockets.foo))

Lumea reala exemplu
chaussette is the perfect Circus companion if you want to run your WSGI application.

Once it's installed, running 5 meinheld workers can be done by creating a socket and
apelând ciorap command in a worker, like this:

[circ]
punct final = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557

[vizionator:web]
cmd = chaussette --fd $(circus.sockets.web) --backend meinheld mycool.app
use_sockets = Adevărat
numprocese = 5

[socket:web]
gazdă = 0.0.0.0
port = 8000

We did not publish benchmarks yet, but a Web cluster managed by Circus with a Gevent or
Meinheld backend is as fast as any pre-fork WSGI server out there.

Utilizarea construit-in Plugin-uri
Circus comes with a few built-in plugins. This section presents these plugins and their
opțiuni de configurare.

Statsd
utilizare set to 'circus.plugins.statsd.StatsdEmitter'

Numele aplicatiei
the name used to identify the bucket prefix to emit the stats to (it will be
prefixat cu circ. and suffixed with .watcher)

gazdă the host to post the statds data to

port the port the statsd daemon listens on

rata simpla
if you prefer a different sample rate than 1, you can set it here

FullStats
An extension on the Statsd plugin that is also publishing the process stats. As such it
has the same configuration options as Statsd and the following.

utilizare setat la circus.plugins.statsd.FullStats

loop_rate
the frequency the plugin should ask for the stats in seconds. Default: 60.

RedisObserver
This services observers a redis process for you, publishes the information to statsd
and offers to restart the watcher when it doesn't react in a given timeout. This plugin
Necesită redis-py a alerga.

It has the same configuration as statsd and adds the following:

utilizare setat la circus.plugins.redis_observer.RedisObserver

loop_rate
the frequency the plugin should ask for the stats in seconds. Default: 60.

redis_url
the database to check for as a redis url. Default: "redis://localhost:6379/0"

timeout
the timeout in seconds the request can take before it is considered down.
Implicit la 5.

restart_on_timeout
the name of the process to restart when the request timed out. No restart
triggered when not given. Default: None.

HttpObserver
This services observers a http process for you by pinging a certain website regularly.
Similar to the redis observer it offers to restart the watcher on an error. It requires
tornadă a alerga.

It has the same configuration as statsd and adds the following:

utilizare setat la circus.plugins.http_observer.HttpObserver

loop_rate
the frequency the plugin should ask for the stats in seconds. Default: 60.

check_url
the url to check for. Default: http://localhost/

timeout
the timeout in seconds the request can take before it is considered down.
Implicit la 10.

restart_on_error
the name of the process to restart when the request timed out or returned any
other kind of error. No restart triggered when not given. Default: None.

ResourceWatcher
This services watches the resources of the given process and triggers a restart when
they exceed certain limitations too often in a row.

It has the same configuration as statsd and adds the following:

utilizare setat la circus.plugins.resource_watcher.ResourceWatcher

loop_rate
the frequency the plugin should ask for the stats in seconds. Default: 60.

Watcher
the watcher this resource watcher should be looking after. (previously called
serviciu dar serviciu is now deprecated)

max_cpu
The maximum cpu one process is allowed to consume (in %). Default: 90

min_cpu
The minimum cpu one process should consume (in %). Default: None (no minimum)
You can set the min_cpu to 0 (zero), in this case if one process consume exactly
0% cpu, it will trigger an exceeded limit.

max_mem
The amount of memory one process of this watcher is allowed to consume. Default:
90. If no unit is specified, the value is in %. Example: 50 If a unit is
specified, the value is in bytes. Supported units are B, K, M, G, T, P, E, Z, Y.
Example: 250M

min_mem
The minimum memory one process of this watcher should consume. Default: None (no
minimum). If no unit is specified, the value is in %. Example: 50 If a unit is
specified, the value is in bytes. Supported units are B, K, M, G, T, P, E, Z, Y.
Example: 250M

health_threshold
The health is the average of cpu and memory (in %) the watchers processes are
allowed to consume (in %). Default: 75

max_count
How often these limits (each one is counted separately) are allowed to be
exceeded before a restart will be triggered. Default: 3

Exemplu:

[circ]
; ...

[watcher:program]
cmd = sleep 120

[plugin:myplugin]
use = circus.plugins.resource_watcher.ResourceWatcher
watcher = program
min_cpu = 10
max_cpu = 70
min_mem = 0
max_mem = 20

Watchdog
Plugin that binds an udp socket and wait for watchdog messages. For "watchdoged"
processes, the watchdog will kill them if they don't send a heartbeat in a certain
period of time materialized by loop_rate * max_count. (circus will automatically
restart the missing processes in the watcher)

Each monitored process should send udp message at least at the loop_rate. The udp
message format is a line of text, decoded using msg_regex parameter. The heartbeat
message MUST at least contain the pid of the process sending the message.

The list of monitored watchers are determined by the parameter watchers_regex în
configurare.

Parametri de configurare:

utilizare setat la circus.plugins.watchdog.WatchDog

loop_rate
watchdog loop rate in seconds. At each loop, WatchDog will looks for "dead"
procese.

watchers_regex
regex for matching watcher names that should be monitored by the watchdog
(Mod implicit: .* all watchers are monitored)

msg_regex
regex for decoding the received heartbeat message in udp (default:
^(?P<pid>.*);(?P<timestamp>.*)$) the default format is a simple text message:
pid;timestamp

max_count
max number of passed loop without receiving any heartbeat before restarting
process (default: 3)

ip ip the watchdog will bind on (default: 127.0.0.1)

port port the watchdog will bind on (default: 1664)

Bătut
When a worker restarts too often, we say that it is flapping. This plugin keeps track
of worker restarts and stops the corresponding watcher in case it is flapping. This
plugin may be used to automatically stop workers that get constantly restarted because
they're not working properly.

utilizare setat la circus.plugins.flapping.Flapping

Încercările
the number of times a process can restart, within fereastră seconds, before we
consider it flapping (default: 2)

fereastră the time window in seconds to test for flapping. If the process restarts more
decât Încercările times within this time window, we consider it a flapping process.
(implicit: 1)

retry_in
time in seconds to wait until we try to start again a process that has been
flapping. (default: 7)

max_retry
the number of times we attempt to start a process that has been flapping, before
we abandon and stop the whole watcher. (default: 5) Set to -1 to disable
max_retry and retry indefinitely.

activ define if the plugin is active or not (default: True). If the global flag is
set to False, the plugin is not started.

Options can be overriden in the watcher section using a flapping. prefix. For instance,
here is how you would configure a specific max_retry value for nginx:

[watcher:nginx]
cmd = /path/to/nginx
flapping.max_retry = 2

[watcher:myscript]
cmd = ./my_script.py

; ... other watchers

[plugin:flapping]
use = circus.plugins.flapping.Flapping
max_retry = 5

CommandReloader
This plugin will restart watchers when their command file is modified. It works by
checking the modification time and the path of the file pointed by the cmd opțiune fiecare
loop_rate seconds. This may be useful while developing worker processes or even for hot
code upgrade in production.

utilizare setat la circus.plugins.command_reloader.CommandReloader

loop_rate
the frequency the plugin should check for modification in seconds. Default: 1.

Implementare
Although the Circus daemon can be managed with the circusd command, it's easier to have it
start on boot. If your system supports Upstart, you can create this Upstart script in
/etc/init/circus.conf.

start on filesystem and net-device-up IFACE=lo
stop on runlevel [016]

respawn
exec /usr/local/bin/circusd /etc/circus/circusd.ini

This assumes that circusd.ini is located at /etc/circus/circusd.ini. After rebooting, you
can control circusd with the service command:

# service circus start/stop/restart

If your system supports systemd, you can create this systemd unit file under
/etc/systemd/system/circus.service.

[Unitate]
Description=Circus process manager
After=syslog.target network.target nss-lookup.target

[Serviciu]
Tip = simplu
ExecReload=/usr/bin/circusctl reload
ExecStart=/usr/bin/circusd /etc/circus/circus.ini
Restart = întotdeauna
RestartSec = 5

[Instalare]
WantedBy=default.target

A reboot isn't required if you run the daemon-reload command below:

# systemctl --system daemon-reload

Then circus can be managed via:

# systemctl start/stop/status/reload circus

Recipes, Romania
This section will contain recipes to deploy Circus. Until then you can look at Pete's
Marionetă reţetă or at Remy's bucătar-șef reţetă

Papă Proces Nucleu
One problem common to process managers is that you cannot restart the process manager
without restarting all of the processes it manages. This makes it difficult to deploy a
new version of Circus or new versions of any of the libraries on which it depends.

If you are on a Unix-type system, Circus can use the Papa process kernel. When used, Papa
will create a long-lived daemon that will serve as the host for any processes and sockets
you create with it. If circus is shutdown, Papa will maintain everything it is hosting.

Configurarea
Începeți prin a instala papa și setproctitle module:

pip install papa
pip install setproctitle

setproctitle module is optional. It will be used if present to rename the Papa daemon
pentru top și ps to something like "papa daemon from circusd". If you do not install the
setproctitle module, that title will be the command line of the process that launched it.
Very confusing.

Once Papa is installed, add use_papa=true to your critical processes and sockets.
Generally you want to house all of the processes of your stack in Papa, and none of the
Circus support processes such as the flapping and stats plugins.

[circ]
loglevel = info

[watcher:nginx]
cmd = /usr/local/nginx/sbin/nginx -p /Users/scottmax/Source/service-framework/Common/conf/nginx -c /Users/scottmax/Source/service-framework/Common/conf/nginx/nginx.conf
întârziere_încălzire = 3
graceful_timeout = 10
max_retry = 5
singleton = true
send_hup = true
stop_signal = QUIT
stdout_stream.class = FileStream
stdout_stream.filename = /var/logs/web-server.log
stdout_stream.max_bytes = 10000000
stdout_stream.backup_count = 10
stderr_stream.class = FileStream
stderr_stream.filename = /var/logs/web-server-error.log
stderr_stream.max_bytes = 1000000
stderr_stream.backup_count = 10
active = true
use_papa = true

[watcher:logger]
cmd = /my_service/env/bin/python logger.py run
working_dir = /my_service
graceful_timeout = 10
singleton = true
stop_signal = INT
stdout_stream.class = FileStream
stdout_stream.filename = /var/logs/logger.log
stdout_stream.max_bytes = 10000000
stdout_stream.backup_count = 10
stderr_stream.class = FileStream
stderr_stream.filename = /var/logs/logger.log
stderr_stream.max_bytes = 1000000
stderr_stream.backup_count = 10
prioritate = 50
use_papa = true

[watcher:web_app]
cmd = /my_service/env/bin/uwsgi --ini uwsgi-live.ini --socket fd://$(circus.sockets.web) --stats 127.0.0.1:809$(circus.wid)
working_dir = /my_service/web_app
graceful_timeout=10
stop_signal = QUIT
use_sockets = Adevărat
stdout_stream.class = FileStream
stdout_stream.filename = /var/logs/web_app.log
stdout_stream.max_bytes = 10000000
stdout_stream.backup_count = 10
stderr_stream.class = FileStream
stderr_stream.filename = /var/logs/web_app.log
stderr_stream.max_bytes = 1000000
stderr_stream.backup_count = 10
hooks.after_spawn = examples.uwsgi_lossless_reload.children_started
hooks.before_signal = examples.uwsgi_lossless_reload.clean_stop
hooks.extended_stats = examples.uwsgi_lossless_reload.extended_stats
prioritate = 40
use_papa = true

[socket:web]
path = /my_service/sock/uwsgi
use_papa = true

[plugin:flapping]
use = circus.plugins.flapping.Flapping
window = 10
prioritate = 1000

NOTĂ:
If the Papa processes use any sockets, those sockets must also use papa.

Amenajări Scop
Papa is designed to be very minimalist in features and requirements. It does:

· Start and stop sockets

· Provide a key/value store

· Start processes and return stdout, stderr and the exit code

It does not:

· Restart processes

· Provide a way to stop processes

· Provide any information about processes other than whether or not they are still running

Papa requires no third-party libraries so it can run on just the standard Python library.
It can make use of the setproctitle package but that is only used for making the title
prettier for ps și top and is not essential.

The functionality has been kept to a minimum so that you should never need to restart the
Papa daemon. As much of the functionality has been pushed to the client library as
possible. That way you should be able to deploy a new copy of Papa for new client features
without needing to restart the Papa daemon. Papa is meant to be a pillar of stability in
a changing sea of 3rd party libraries.

Ziua Operației
Most things remain unchanged whether you use Papa or not. You can still start and stop
processes. You can still get status and stats for processes. The main thing that changes
is that when you do circ părăsi, all of the Papa processes are left running. When you
Începe circ back up, those processes are recovered.

NOTĂ:
When processes are recovered, înainte_începe și inainte de_aparitie hooks are skipped.

Exploatari forestiere
While Circus is shut down, Papa will store up to 2M of output per process. Then it will
start dumping the oldest data. When you restart Circus, this cached output will be quickly
retrieved and sent to the output streams. Papa requires that receipt of output be
acknowledged, so you should not lose any output during a shutdown.

Not only that, but Papa saves the timestamp of the output. Circus has been enhanced to
take advantage of timestamp data if present. So if you are writing the output to log files
or somewhere, your timestamps should all be correct.

Probleme
Dacă utilizați incr or decr command to change the process count for a watcher, this will
be reset to the level specified in the INI file when circ este repornit.

Also, I have experienced problems with the combination of copy_env și virtualenv. Puteți
note that the INI sample above circumvents this issue with explicit paths.

Telnet interfaţă
Papa has a basic command-line interface that you can access through telnet:

telnet localhost 20202
ajutor

Circ pentru Dezvoltatorii
Utilizarea Circ as a bibliotecă
Circus provides high-level classes and functions that will let you manage processes in
your own applications.

For example, if you want to run four processes forever, you could write:

from circus import get_arbiter

myprogram = {"cmd": "python myprogram.py", "numprocesses": 4}

arbiter = get_arbiter([myprogram])
încerca:
arbiter.start()
in cele din urma:
arbiter.stop()

This snippet will run four instances of programul meu and watch them for you, restarting them
if they die unexpectedly.

To learn more about this, see library

Extinderea Circ
It's easy to extend Circus to create a more complex system, by listening to all the
circ events via its pub/sub channel, and driving it via commands.

That's how the flapping feature works for instance: it listens to all the processes dying,
measures how often it happens, and stops the incriminated watchers after too many restarts
încercări.

Circus comes with a plugin system to help you write such extensions, and a few built-in
plugins you can reuse. See plugins.

You can also have a more subtile startup and shutdown behavior by using the cârlige sistem
that will let you run arbitrary code before and after some processes are started or
stopped. See hooks.

Last but not least, you can also add new commands. See addingcmds.

Dezvoltatorii Documentație index
Circ Bibliotecă
The Circus package is composed of a high-level get_arbiter() function and many classes. In
most cases, using the high-level function should be enough, as it creates everything that
is needed for Circus to run.

You can subclass Circus' classes if you need more granularity than what is offered by the
configurare.

get_arbiter funcţie
get_arbiter() is just a convenience on top of the various circus classes. It creates a
arbiter (class Arbitru) instance with the provided options, which in turn runs a single
Watcher cu un singur Proces.

circus.get_arbiter()

Exemplu:

from circus import get_arbiter

arbiter = get_arbiter([{"cmd": "myprogram", "numprocesses": 3}])
încerca:
arbiter.start()
in cele din urma:
arbiter.stop()

Clase
Circus provides a series of classes you can use to implement your own process manager:

· Proces: wraps a running process and provides a few helpers on top of it.

· Watcher: run several instances of Proces against the same command. Manage the death and
life of processes.

· Arbitru: manages several Watcher.

clasă circus.process.Process(name, wid, cmd, args=None, working_dir=None, shell=False,
uid=None, gid=None, env=None, rlimits=None, executable=None, use_fds=False, watcher=None,
spawn=True, pipe_stdout=True, pipe_stderr=True, close_child_stdout=False,
close_child_stderr=False)
Wraps a process.

Opțiuni:

· WID: the process unique identifier. This value will be used to replace the $WID
string in the command line if present.

· cmd: the command to run. May contain any of the variables available that are
being passed to this class. They will be replaced using the python format syntax.

· args: the arguments for the command to run. Can be a list or a string. If args is
a string, it's splitted using shlex.split(). Implicit la Niciunul.

· executabil: When executable is given, the first item in the args sequence
obtinut de la cmd is still treated by most programs as the command name, which
can then be different from the actual executable name. It becomes the display
name for the executing program in utilities such as ps.

· dir_de lucru: the working directory to run the command in. If not provided, will
default to the current working directory.

· coajă: dacă Adevărat, will run the command in the shell environment. Fals în mod implicit.
avertizare: acest is a securitate risc.

· uid: if given, is the user id or name the command should run with. The current
uid is the default.

· ghid: if given, is the group id or name the command should run with. The current
gid is the default.

· env: a mapping containing the environment variables the command will run with.
Opțional.

· rlimits: a mapping containing rlimit names and values that will be set before the
comanda rulează.

· use_fds: if True, will not close the fds in the subprocess. Must be be set to
True on Windows if stdout or stderr are redirected. default: False.

· pipe_stdout: if True, will open a PIPE on stdout. default: True.

· pipe_stderr: if True, will open a PIPE on stderr. default: True.

· close_child_stdout: If True, redirects the child process' stdout to /dev/null
after the fork. default: False.

· close_child_stderr: If True, redirects the child process' stdout to /dev/null
after the fork. default: False.

age() Return the age of the process in seconds.

copii()
Return a list of children pids.

info () Return process info.

The info returned is a mapping with these keys:

· mem_info1: Resident Set Size Memory in bytes (RSS)

· mem_info2: Virtual Memory Size in bytes (VMS).

· cpu: % of cpu usage.

· în sine: % of memory usage.

· ctime: process CPU (user + system) time in seconds.

· pid: process id.

· nume de utilizator: user name that owns the process.

· frumos: process niceness (between -20 and 20)

· cmdline: the command line the process was run with.

is_child(pid)
Return True is the given pid is a child of that process.

pid Returnează pid

send_signal(*args, **kw)
Sends a signal sig la proces.

send_signal_child(*args, **kw)
Trimite semnal semnum to child pid.

send_signal_children(*args, **kw)
Trimite semnal semnum to all children.

Starea Return the process status as a constant

· RUNNING

· DEAD_OR_ZOMBIE

· UNEXISTING

· ALTE

stderr Returnează stdout curent

stdout Returnează stdout curent

stop(*args, **kw)
Stop the process and close stdout/stderr

If the corresponding process is still here (normally it's already killed by
the watcher), a SIGTERM is sent, then a SIGKILL after 1 second.

The shutdown process (SIGTERM then SIGKILL) is normally taken by the
watcher. So if the process is still there here, it's a kind of bad behavior
because the graceful timeout won't be respected here.

Exemplu:

>>> from circus.process import Process
>>> process = Process('Top', 'top', shell=True)
>>> process.age()
3.0107998847961426
>>> process.info()
'Top: 6812 N/A tarek Zombie N/A N/A N/A N/A N/A'
>>> process.status
1
>>> process.stop()
>>> process.status
2
>>> process.info()
'No such process (stopped?)'

clasă circus.watcher.Watcher(name, cmd, args=None, numprocesses=1, warmup_delay=0.0,
working_dir=None, shell=False, shell_args=None, uid=None, max_retry=5, gid=None,
send_hup=False, stop_signal=15, stop_children=False, env=None, graceful_timeout=30.0,
prereload_fn=None, rlimits=None, executable=None, stdout_stream=None, stderr_stream=None,
priority=0, loop=None, singleton=False, use_sockets=False, copy_env=False,
copy_path=False, max_age=0, max_age_variance=30, hooks=None, respawn=True, autostart=True,
on_demand=False, virtualenv=None, close_child_stdout=False, close_child_stderr=False,
virtualenv_py_ver=None, use_papa=False, **Opțiuni)
Class managing a list of processes for a given command.

Opțiuni:

· nume: name given to the watcher. Used to uniquely identify it.

· cmd: the command to run. May contain $WID, which will be replaced by WID.

· args: the arguments for the command to run. Can be a list or a string. If args is
a string, it's splitted using shlex.split(). Implicit la Niciunul.

· numprocese: Number of processes to run.

· dir_de lucru: the working directory to run the command in. If not provided, will
default to the current working directory.

· coajă: dacă Adevărat, will run the command in the shell environment. Fals în mod implicit.
avertizare: acest is a securitate risc.

· uid: if given, is the user id or name the command should run with. The current
uid is the default.

· ghid: if given, is the group id or name the command should run with. The current
gid is the default.

· trimite_hup: if True, a process reload will be done by sending the SIGHUP signal.
Defaults to False.

· semnal_oprire: the signal to send when stopping the process. Defaults to SIGTERM.

· stop_copii: send the semnal_oprire to the children too. Defaults to False.

· env: a mapping containing the environment variables the command will run with.
Opțional.

· rlimits: a mapping containing rlimit names and values that will be set before the
comanda rulează.

· stdout_stream: a mapping that defines the stream for the process stdout. Defaults
to None.

Optional. When provided, stdout_stream is a mapping containing up to three keys:

· clasă: the stream class. Defaults to circus.stream.FileStream

· nume de fișier: the filename, if using a FileStream

· max_bytes: maximum file size, after which a new output file is opened. defaults
to 0 which means no maximum size (only applicable with FileStream).

· backup_count: how many backups to retain when rotating files according to the
max_bytes parameter. defaults to 0 which means no backups are made (only
applicable with FileStream)

This mapping will be used to create a stream callable of the specified class.
Each entry received by the callable is a mapping containing:

· pid - the process pid

· nume - the stream name (stderr or stdout)

· de date - the data

This is not supported on Windows.

· stderr_stream: a mapping that defines the stream for the process stderr. Defaults
to None.

Optional. When provided, stderr_stream is a mapping containing up to three keys:
- clasă: the stream class. Defaults to circus.stream.FileStream - nume de fișier:
filename, if using a FileStream - max_bytes: maximum file size, after which a new
output file is
opened. defaults to 0 which means no maximum size (only applicable with
FileStream)

· backup_count: how many backups to retain when rotating files according to the
max_bytes parameter. defaults to 0 which means no backups are made (only
applicable with FileStream).

This mapping will be used to create a stream callable of the specified class.

Each entry received by the callable is a mapping containing:

· pid - the process pid

· nume - the stream name (stderr or stdout)

· de date - the data

This is not supported on Windows.

· prioritate -- integer that defines a priority for the watcher. When the Arbiter do
some operations on all watchers, it will sort them with this field, from the
bigger number to the smallest. (default: 0)

· Singleton -- If True, this watcher has a single process. (default:False)

· use_sockets -- If True, the processes will inherit the file descriptors, thus can
reuse the sockets opened by circusd. (default: False)

· la cerere -- If True, the processes will be started only at the first connection
to the socket (default: False)

· copy_env -- If True, the environment in which circus is running run will be
reproduced for the workers. This defaults to True on Windows as you cannot run
any executable without the SYSTEMROOT variable. (default: False)

· copy_path -- If True, circusd sys.path is sent to the process through PYTHONPATH.
Trebuie să activați copy_env pentru copy_path to work. (default: False)

· varsta_max: If set after around max_age seconds, the process is replaced with a new
one. (default: 0, Disabled)

· varianță_vârstă_max: The maximum number of seconds that can be added to max_age.
This extra value is to avoid restarting all processes at the same time. A
process will live between max_age and max_age + max_age_variance seconds.

· cârlige: callback functions for hooking into the watcher startup and shutdown
proces. cârlige is a dict where each key is the hook name and each value is a
2-tuple with the name of the callable or the callabled itself and a boolean flag
indicating if an exception occuring in the hook should not be ignored. Possible
values for the hook name: înainte_începe, after_start, inainte de_aparitie, after_spawn,
înainte_stop, după_oprire., înainte_semnal, după_semnal or statistici_extinse.

· Opțiuni -- extra options for the worker. All options found in the configuration
file for instance, are passed in this mapping -- this can be used by plugins for
watcher-specific options.

· respawn -- If set to False, the processes handled by a watcher will not be
respawned automatically. (default: True)

· virtualenv -- The root directory of a virtualenv. If provided, the watcher will
load the environment for its execution. (default: None)

· close_child_stdout: If True, closes the stdout after the fork. default: False.

· close_child_stderr: If True, closes the stderr after the fork. default: False.

· use_papa: If True, use the papa process kernel for this process. default: False.

kill_process(*args, **kwargs)
Kill process (stop_signal, graceful_timeout then SIGKILL)

kill_processes(*args, **kwargs)
Kill all processes (stop_signal, graceful_timeout then SIGKILL)

manage_processes(*args, **kwargs)
Manage processes.

notify_event(topic, mesaj)
Publish a message on the event publisher channel

reap_and_manage_processes(*args, **kwargs)
Reap & manage processes.

reap_processes(*args, **kw)
Reap all the processes for this watcher.

send_signal_child(*args, **kw)
Send signal to a child.

spawn_process(recovery_wid=None)
Spawn process.

Return True if ok, False if the watcher must be stopped

spawn_processes(*args, **kwargs)
Spawn processes.

clasă circus.arbiter.Arbiter(watchers, endpoint, pubsub_endpoint, check_delay=1.0,
prereload_fn=None, context=None, loop=None, statsd=False, stats_endpoint=None,
statsd_close_outputs=False, multicast_endpoint=None, plugins=None, sockets=None,
warmup_delay=0, httpd=False, httpd_host='localhost', httpd_port=8080,
httpd_close_outputs=False, debug=False, debug_gc=False, ssh_server=None,
proc_name='circusd', pidfile=None, loglevel=None, logoutput=None, loggerconfig=None,
fqdn_prefix=None, umask=None, endpoint_owner=None, papa_endpoint=None)
Class used to control a list of watchers.

Opțiuni:

· observatorii -- a list of Watcher objects

· punct final -- the controller ZMQ endpoint

· pubsub_endpoint -- the pubsub endpoint

· statsd -- If True, a circusd-stats process is run (default: False)

· stats_endpoint -- the stats endpoint.

· statsd_close_outputs -- if True sends the circusd-stats stdout/stderr to
/dev/null (default: False)

· multicast_endpoint -- the multicast endpoint for circusd cluster auto-discovery
(default: udp://237.219.251.97:12027) Multicast addr should be between 224.0.0.0
to 239.255.255.255 and the same for the all cluster.

· check_delay -- the delay between two controller points (default: 1 s)

· prereload_fn -- callable that will be executed on each reload (default: None)

· context -- if provided, the zmq context to reuse. (default: None)

·

buclă: if cu condiția, a zmq.eventloop.ioloop.IOLoop instanță
to reuse. (default: None)

· Plugin-uri -- a list of plugins. Each item is a mapping with:

· utilizare -- Fully qualified name that points to the plugin class

· every other value is passed to the plugin in the config opțiune

· prize -- a mapping of sockets. Each key is the socket name, and each value a
CircusSocket class. (default: None)

· întârziere_încălzire -- a delay in seconds between two watchers startup. (default: 0)

· httpd -- If True, a circushttpd process is run (default: False)

· httpd_host -- the circushttpd host (default: localhost)

· httpd_port -- the circushttpd port (default: 8080)

· httpd_close_outputs -- if True, sends circushttpd stdout/stderr to /dev/null.
(implicit: fals)

· depana -- if True, adds a lot of debug info in the stdout (default: False)

· debug_gc -- if True, does gc.set_debug(gc.DEBUG_LEAK) (default: False) to circusd
to analyze problems (default: False)

· proc_name -- the arbiter process name

·

fqdn_prefix -- a prefix pentru il unic identificator of il circ
instance on the cluster.

· endpoint_owner -- unix user to chown the endpoint to if using ipc.

· papa_endpoint -- the papa process kernel endpoint

add_watcher(*args, **kwargs)
Adds a watcher.

Opțiuni:

· nume: name of the watcher to add

· cmd: command to run.

· all other options defined in the Watcher constructor.

get_watcher(name)
Return the watcher nume.

numprocesses()
Return the number of processes running across all watchers.

numwatchers()
Return the number of watchers.

reload(*args, **kwargs)
Reloads everything.

Pornește prereload_fn() callable if any, then gracefuly reload all watchers.

start(*args, **kwargs)
Starts all the watchers.

If the ioloop has been provided during __init__() call, starts all watchers
as a standard coroutine

If the ioloop hasn't been provided during __init__() call (default), starts
all watchers and the eventloop (and blocks here). In this mode the method
MUST NOT yield anything because it's called as a standard method.

parametrii
cb -- Callback called after all the watchers have been started, when
the loop hasn't been provided.

Scris Plugin-uri
Circus comes with a plugin system which lets you interact with circ.

NOTĂ:
We might add circusd-stats support to plugins later on.

A Plugin is composed of two parts:

· a ZMQ subscriber to all events published by circ

· a ZMQ client to send commands to circ

Each plugin is run as a separate process under a custom watcher.

A few examples of some plugins you could create with this system:

· a notification system that sends e-mail alerts when a watcher is flapping

· a logger

· a tool that adds or removes processes depending on the load

· etc.

Circus itself comes with a few built-in plugins.

CircusPlugin clasă
Circus provides a base class to help you implement plugins: circus.plugins.CircusPlugin

clasă circus.plugins.CircusPlugin(endpoint, pubsub_endpoint, check_delay, ssh_server=None,
**config)
Base class to write plugins.

Opțiuni:

· context -- the ZMQ context to use

· punct final -- the circusd ZMQ endpoint

· pubsub_endpoint -- the circusd ZMQ pub/sub endpoint

· check_delay -- the configured check delay

· config -- free config mapping

call(command, **props)
Sends the command to circ

Opțiuni:

· comandă -- the command to call

· recuzită -- keyword arguments to add to the call

Returns the JSON mapping sent back by circ

cast(command, **props)
Fire-and-forget a command to circ

Opțiuni:

· comandă -- the command to call

· recuzită -- keyword arguments to add to the call

handle_init()
Called right before a plugin is started - in the thread context.

handle_recv(data)
Receives every event published by circ

Opțiuni:

· de date -- a tuple containing the topic and the message.

handle_stop()
Called right before the plugin is stopped by Circus.

When initialized by Circus, this class creates its own event loop that receives all
circ events and pass them to handle_recv(). The data received is a tuple containing the
topic and the data itself.

handle_recv() trebuie sa be implemented by the plugin.

apel() și cast() methods can be used to interact with circ if you are building a
Plugin that actively interacts with the daemon.

handle_init() și handle_stop() are just convenience methods you can use to initialize and
clean up your code. handle_init() is called within the thread that just started.
handle_stop() is called in the main thread just before the thread is stopped and joined.

Scris a conecteaza
Let's write a plugin that logs in a file every event happening in circ. Este nevoie de unul
argument which is the filename.

The plugin may look like this:

from circus.plugins import CircusPlugin

class Logger(CircusPlugin):

name = 'logger'

def __init__(self, *args, **config):
super(Logger, self).__init__(*args, **config)
self.filename = config.get('filename')
self.file = None

def handle_init(self):
self.file = open(self.filename, 'a+', buffering=1)

def handle_stop(self):
self.file.close()

def handle_recv(self, data):
watcher_name, action, msg = self.split_data(data)
msg_dict = self.load_message(mesaj)
self.file.write('%s %s::%r\n' % (action, watcher_name, msg_dict))

That's it ! This class can be saved in any package/module, as long as it can be seen by
Python.

De exemplu, Logger may be found in a Plugin-uri module within a proiectul meu pachet.

async cereri de
In case you want to make any asynchronous operations (like a Tornado call or using
periodicCall) make sure you are using the right loop. The loop you always want to be using
is self.loop as it gets set up by the base class. The default loop often isn't the same
and therefore code might not get executed as expected.

încercat a conecteaza
You can run a plugin through the command line with the circ-plugin command, by
specifying the plugin fully qualified name:

$ circus-plugin --endpoint tcp://127.0.0.1:5555 --pubsub tcp://127.0.0.1:5556 --config filename:circus-events.log myproject.plugins.Logger
[INFO] Loading the plugin...
[INFO] Endpoint: 'tcp://127.0.0.1:5555'
[INFO] Pub/sub: 'tcp://127.0.0.1:5556'
[INFO] Starting

Another way to run a plugin is to let Circus handle its initialization. This is done by
adăugând un [plugin:NAME] section in the configuration file, where NUME is a unique name for
your plugin:

[plugin:logger]
use = myproject.plugins.Logger
filename = /var/myproject/circus.log

utilizare is mandatory and points to the fully qualified name of the plugin.

When Circus starts, it creates a watcher with one process that runs the pointed class, and
pass any other variable contained in the section to the plugin constructor via the config
cartografiere.

You can also programmatically add plugins when you create a circus.arbiter.Arbiter clasă
sau utilizare circus.get_arbiter(), see library.

Spectacole
Since every plugin is loaded in its own process, it should not impact the overall
performances of the system as long as the work done by the plugin is not doing too many
apeluri la circ proces.

cârlige
Circus provides hooks that can be used to trigger actions upon watcher events. Available
hooks are:

· înainte_începe: called before the watcher is started. If the hook returns Fals il
startup is aborted.

· after_start: called after the watcher is started. If the hook returns Fals the watcher
is immediately stopped and the startup is aborted.

· inainte de_aparitie: called before the watcher spawns a new process. If the hook returns Fals
the watcher is immediately stopped and the startup is aborted.

· after_spawn: called after the watcher spawns a new process. If the hook returns Fals
the watcher is immediately stopped and the startup is aborted.

· înainte_stop: called before the watcher is stopped. The hook result is ignored.

· după_oprire: called after the watcher is stopped. The hook result is ignored.

· înainte_semnal: called before a signal is sent to a watcher's process. If the hook
Returnează Fals the signal is not sent (except SIGKILL which is always sent)

· după_semnal: called after a signal is sent to a watcher's process.

· statistici_extinse: called when stats are requested with extended=True. Used for adding
process-specific stats to the regular stats output.

Exemplu
A typical use case is to control that all the conditions are met for a process to start.
Let's say you have a watcher that runs Redis and a watcher that runs a Python script that
lucrări cu Redis. With Circus you can order the startup by using the prioritate opţiune:

[watcher:queue-worker]
cmd = python -u worker.py
prioritate = 1

[watcher:redis]
cmd = redis-server
prioritate = 2

With this setup, Circus will start Redis first and then it will start the queue worker.
But Circus does not really control that Redis is up and running. It just starts the
process it was asked to start. What we miss here is a way to control that Redis is
started and fully functional. A function that controls this could be:

import redis
timp de import

def check_redis(*args, **kw):
time.sleep(.5) # give it a chance to start
r = redis.StrictRedis(host='localhost', port=6379, db=0)
r.set('foo', 'bar')
return r.get('foo') == 'bar'

This function can be plugged into Circus as an înainte_începe cârlig:

[watcher:queue-worker]
cmd = python -u worker.py
hooks.before_start = mycoolapp.myplugins.check_redis
prioritate = 1

[watcher:redis]
cmd = redis-server
prioritate = 2

Once Circus has started the Redis watcher, it will start the queue-worker watcher, since
it follows the prioritate ordering. Just before starting the second watcher, it will run
il check_redis function, and in case it returns Fals will abort the watcher starting
proces.

Cârlig semnătură
A hook must follow this signature:

def hook(watcher, arbiter, hook_name, **kwargs):
...
# If you don't return True, the hook can change
# the behavior of circus (depending on the hook)
returnează Adevărat

Unde Watcher este Watcher class instance, arbitru il Arbitru unu, hook_name carligul
numele și kwargs some additional optional parameters (depending on the hook type).

after_spawn hook adds the pid parameters:

def after_spawn(watcher, arbiter, hook_name, pid, **kwargs):
...
# If you don't return True, circus will kill the process
returnează Adevărat

Unde pid is the PID of the corresponding process.

De asemenea, înainte_semnal și după_semnal hooks add pid and signum:

def before_signal_hook(watcher, arbiter, hook_name, pid, signum, **kwargs):
...
# If you don't return True, circus won't send the signum signal
# (SIGKILL is always sent)
returnează Adevărat

Unde pid is the PID of the corresponding process and semnum is the corresponding signal.

You can ignore those but being able to use the watcher and/or arbiter data and methods can
be useful in some hooks.

Note that hooks are called with named arguments. So use the hook signature without
changing argument names.

statistici_extinse hook has its own additional parameters in kwargs:

def extended_stats_hook(watcher, arbiter, hook_name, pid, stats, **kwargs):
...

Unde pid is the PID of the corresponding process and Statistici the regular stats to be
returned. Add your own stats into Statistici. An example is in
examples/uwsgi_lossless_reload.py.

As a last example, here is a super hook which can deal with all kind of signals:

def super_hook(watcher, arbiter, hook_name, **kwargs):
pid = None
signum = None
if hook_name in ('before_signal', 'after_signal'):
pid = kwargs['pid']
signum = kwargs['signum']
...
returnează Adevărat

Cârlig evenimente
Everytime a hook is run, its result is notified as an event in Circus.

There are two events related to hooks:

· hook_success: a hook was successfully called. The event keys are nume the name if the
eveniment, și timp: the date of the events.

· hook_failure: a hook has failed. The event keys are nume the name if the event, timp:
the date of the events and eroare: the exception that occurred in the event, if any.

Adăugare nou comenzi
We tried to make adding new commands as simple as possible.

You need to do three things:

1. create a your_command.py fișier sub circus/commands/.

2. Implement a single class in there, with predefined methods

3. Add the new command in circus/commands/__init__.py.

Let's say we want to add a command which returns the number of watchers currently in use,
we would do something like this (extensively commented to allow you to follow more
easily):

from circus.commands.base import Command
from circus.exc import ArgumentError, MessageError
class NumWatchers(Command):
"""It is a good practice to describe what the class does here.

Have a look at other commands to see how we are used to format
this text. It will be automatically included in the documentation,
so don't be affraid of being exhaustive, that's what it is made
pentru.
"" "
# all the commands inherit from `circus.commands.base.Command`

# you need to specify a name so we find back the command somehow
name = "numwatchers"

# Set waiting to True or False to define your default behavior
# - If waiting is True, the command is run synchronously, and the client may get
# back results.
# - If waiting is False, the command is run asynchronously on the server and the client immediately
# gets back an 'ok' response
#
# By default, commands are set to waiting = False
waiting = True

# options
options = [('', 'optname', default_value, 'description')]

properties = ['foo', 'bar']
# properties list the command arguments that are mandatory. If they are
# not provided, then an error will be thrown

def execute(self, arbiter, props):
# the execute method is the core of the command: put here all the
# logic of the command and return a dict containing the values you
# want to return, if any
return {"numwatchers": arbiter.numwatchers()}

def console_msg(self, msg):
# msg is what is returned by the execute method.
# this method is used to format the response for a console (it is
# used for instance by circusctl to print its messages)
return "a string that will be displayed"

def message(self, *args, **opts):
# message handles console input.
# this method is used to map console arguments to the command
# options. (its is used for instance when calling the command via
# circusctl)
# NotImplementedError will be thrown if the function is missing
numArgs = 1
if not len(args) == numArgs:
raise ArgumentError('Invalid number of arguments.')
altceva:
opts['optname'] = args[0]
return self.make_message(**opts)

def validate(self, props):
# this method is used to validate that the arguments passed to the
# command are correct. An ArgumentError should be thrown in case
# there is an error in the passed arguments (for instance if they
# do not match together.
# In case there is a problem wrt their content, a MessageError
# should be thrown. This method can modify the content of the props
# dict, it will be passed to execute afterwards.

Utilizare cazuri exemple
This chapter presents a few use cases, to give you an idea on how to use Circus in your
mediu. (envrironment)

Alergare a WSGI cerere
Running a WSGI application with Circus is quite interesting because you can watch & manage
ta web muncitorii folosind blatul de circ, circ or the Web interface.

This is made possible by using Circus sockets. See whycircussockets.

Let's take an example with a minimal Piramidă aplicare:

from pyramid.config import Configurator
from pyramid.response import Response

def hello_world(request):
return Response('Hello %(name)s!' % request.matchdict)

config = Configurator()
config.add_route('hello', '/hello/{name}')
config.add_view(hello_world, route_name='hello')
application = config.make_wsgi_app()

Save this script into an app.py file, then install those projects:

$ pip install Pyramid
$ pip install chaussette

Next, make sure you can run your Pyramid application using the ciorap console script:

$ chaussette app.application
Application is <pyramid.router.Router object at 0x10a4d4bd0>
Servire pe localhost:8080
Using <class 'chaussette.backend._waitress.Server'> as a backend

And check that you can reach it by visiting http://localhost:8080/hello/tarek

Now that your application is up and running, let's create a Circus configuration file:

[circ]
check_delay = 5
punct final = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557

[watcher:webworker]
cmd = chaussette --fd $(circus.sockets.webapp) app.application
use_sockets = Adevărat
numprocese = 3

[socket:webapp]
gazdă = 127.0.0.1
port = 8080

This file tells Circus to bind a socket on port 8080 și fugi ciorap workers on that
socket -- by passing its fd.

Save it to server.ini and try to run it using circ

$ circusd server.ini
[INFO] Starting master on pid 8971
[INFO] sockets started
[INFO] circusd-stats started
[INFO] webapp started
[INFO] Arbiter now waiting for commands

Make sure you still get the app on http://localhost:8080/hello/tarek.

Congrats ! you have a WSGI application running 3 workers.

You can run the circushttpd or the cli, and enjoy Circus management.

Alergare a Django cerere
Running a Django application is done exactly like running a WSGI application. Use the
PYTHONPATH to import the directory the project is in, the directory that contains the
directory that has settings.py in it (with Django 1.4+ this directory has manage.py in it)
:

[socket:dwebapp]
gazdă = 127.0.0.1
port = 8080

[watcher:dwebworker]
cmd = chaussette --fd $(circus.sockets.dwebapp) dproject.wsgi.application
use_sockets = Adevărat
numprocese = 2

[env:dwebworker]
PYTHONPATH = /path/to/parent-of-dproject

If you need to pass the DJANGO_SETTINGS_MODULE for a backend worker for example, you can
pass that also though the env configation option:

[watcher:dbackend]
cmd = /path/to/script.py
numprocesses=3

[env:dbackend]
PYTHONPATH = /path/to/parent-of-dproject
DJANGO_SETTINGS_MODULE=dproject.settings

Vedea http://chaussette.readthedocs.org for more about chaussette.

Amenajări Deciziile
Salopete arhitectură
[Image]

Circus is composed of a main process called circ which takes care of running all the
proceselor. Fiecare proces gestionat de Circus este un proces copil al circ.

Processes are organized in groups called observatorii. O Watcher is basically a command
circ runs on your system, and for each command you can configure how many processes you
vreau să alerg.

Conceptul de Watcher is useful when you want to manage all the processes running the
same command -- like restart them, etc.

circ binds two ZeroMQ sockets:

· REQ/REP -- a socket used to control circ using json-based comenzi.

· PUB/SUB -- a socket where circ publishes events, like when a process is started or
oprit.

NOTĂ:
Despite its name, ZeroMQ is not a queue management system. Think of it as an
inter-process communication (IPC) library.

Another process called circ-stats este condus de circ when the option is activated.
circ-stats's job is to publish CPU/Memory usage statistics in a dedicated PUB/SUB
canal.

This specialized channel is used by blatul de circ și circus-httpd to display a live stream
of the activity.

blatul de circ is a console script that mimics top to display all the CPU and Memory usage of
the processes managed by Circus.

circus-httpd is the web managment interface that will let you interact with Circus. It
displays a live stream using web sockets and the circ-stats channel, but also let you
a interactiona cu circ prin intermediul acestuia REQ/REP canal.

, Ultimul, dar nu cel din circ is a command-line tool that let you drive circ prin intermediul acestuia
REQ/REP canal.

You can also have plugins that subscribe to circ's PUB/SUB channel and let you send
comenzi către REQ/REP channel like circ ar fi.

Securitate
Circus is built on the top of the ZeroMQ library and comes with no security at all in its
protocols. However, you can run a Circus system on a server and set up an SSH tunnel to
access it from another machine.

This section explains what Circus does on your system when you run it, and ends up
describing how to use an SSH tunnel.

De asemenea, puteți citi http://www.zeromq.org/area:faq#toc5

TCP porturi
By default, Circus opens the following TCP ports on the local host:

· 5555 -- the port used to control circus via circ

· 5556 -- the port used for the Publisher/Subscriber channel.

· 5557 -- the port used for the statistics channel -- if activated.

· 8080 -- the port used by the Web UI -- if activated.

These ports allow client apps to interact with your Circus system, and depending on how
your infrastructure is organized, you may want to protect these ports via firewalls or
configure Circus to run using IPC porturi.

Here's an example of running Circus using only IPC entry points:

[circ]
check_delay = 5
endpoint = ipc:///var/circus/endpoint
pubsub_endpoint = ipc:///var/circus/pubsub
stats_endpoint = ipc:///var/circus/stats

When Configured using IPC, the commands must be run from the same box, but no one can
access them from outside, unlike using TCP. The commands must also be run as a user that
has write access to the ipc socket paths. You can modify the owner of the punct final folosind
il endpoint_owner config option. This allows you to run circusd as the root user, but
allow non-root processes to send commands to circ. Note that when using endpoint_owner,
in order to prevent non-root processes from being able to start arbitrary processes that
run with greater privileges, the add command will enforce that new Watchers must run as
il endpoint_owner user. Watcher definitions in the local config files will not be
restricted this way.

Of course, if you activate the Web UI, the 8080 port will still be open.

circhttpd
Când alergi circhttpd manually, or when you use the httpd option in the ini file like
acest:

[circ]
check_delay = 5
endpoint = ipc:///var/circus/endpoint
pubsub_endpoint = ipc:///var/circus/pubsub
stats_endpoint = ipc:///var/circus/stats
httpd = 1

The web application will run on port 8080 and will let anyone accessing the web page
gestionați circ demonul.

That includes creating new watchers that can run any command on your system !

Do nu face it public disponibil

If you want to protect the access to the web panel, you can serve it behind Nginx or
Apache or any proxy-capable web server, that can take care of the security.

Utilizator și grup Permisiuni
By default, all processes started with Circus will be running with the same user and group
as circ. Depending on the privileges the user has on the system, you may not have
access to all the features Circus provides.

For instance, some statistics features on a running processes require extended privileges.
Typically, if the CPU usage numbers you get using the Statistici comanda sunt -, înseamnă că
user can't access the proc files. This will be the case by default under Mac OS X.

Poți fugi circ as root to fix this, and set the uid și ghid values for each watcher
to get all the features.

But beware that running circ as root exposes you to potential privilege escalation
bugs. While we're doing our best to avoid any bugs, running as root and facing a bug that
performs unwanted actions on your system may be dangerous.

The best way to prevent this is to make sure that the system running Circus is completely
isolated (like a VM) or to run the whole system under a controlled user.

SSH tunelelor
Clients can connect to a circ instance by creating an SSH tunnel. To do so, pass the
opțiunea de linie de comandă --ssh urmată de user@address, În cazul în care utilizator is the user on the remote
server și adresa is the server's address as seen by the client. The SSH protocol will
require credentials to complete the login.

If circ as seen by the SSH server is not at the default endpoint address localhost: 5555
then specify the circ address using the option --punct final

securizat configurarea exemplu
Setting up a secured Circus server can be done by:

· Running an SSH Server

· Running Apache or Nginx on the 80 port, and doing a reverse-proxy on the 8080 port.

· Blocking the 8080 port from outside access.

· Running all ZMQ Circusd ports using IPC files instead of TCP ports, and tunneling all
calls via SSH.
[Image]

Contribuind la Circ
Circus has been started at Mozilla but its goal is not to stay only there. We're trying
to build a tool that's useful for others, and easily extensible.

We really are open to any contributions, in the form of code, documentation, discussions,
feature proposal etc.

You can start a topic in our mailing list : http://tech.groups.yahoo.com/group/circus-dev/

Or add an issue in our bug tracker

De stabilire typos și consolidarea il documentaţie
It's totally possible that your eyes are bleeding while reading this half-english
half-french documentation, don't hesitate to contribute any rephrasing / enhancement on
the form in the documentation. You probably don't even need to understand how Circus works
under the hood to do that.

Adăugare nou caracteristici
New features are of course very much appreciated. If you have the need and the time to
work on new features, adding them to Circus shouldn't be that complicated. We tried very
hard to have a clean and understandable API, hope it serves the purpose.

You will need to add documentation and tests alongside with the code of the new feature.
Otherwise we'll not be able to accept the patch.

Cum la prezenta ta schimbari
We're using git as a DVCS. The best way to propose changes is to create a branch on your
side (via merge verificare -b nume de ramură) and commit your changes there. Once you have
something ready for prime-time, issue a pull request against this branch.

We are following this model to allow to have low coupling between the features you are
proposing. For instance, we can accept one pull request while still being in discussion
pentru altul.

Before proposing your changes, double check that they are not breaking anything! You can
utilizați Tox command to ensure this, it will run the testsuite under the different
supported python versions.

Please use : http://issue2pr.herokuapp.com/ to reference a commit to an existing circus
issue, if any.

evitând îmbina comite
Avoiding merge commits allows to have a clean and readable history. To do so, instead of
doing "git pull" and letting git handling the merges for you, using git pull --rebase will
put your changes after the changes that are commited in the branch, or when working on
maestru.

That is, for us core developers, it's not possible anymore to use the handy github green
button on pull requests if developers didn't rebased their work themselves or if we wait
too much time between the request and the actual merge. Instead, the flow looks like this:

git remote add name repo-url
git fetch name
git checkout feature-branch
git rebase master

# check that everything is working properly and then merge on master
git checkout master
git merge feature-branch

discutând
If you find yourself in need of any help while looking at the code of Circus, you can go
and find us on irc at #cort-circ on irc.freenode.org (or if you don't have any IRC
client, use il chat web)

You can also start a thread in our mailing list -
http://tech.groups.yahoo.com/group/circus-dev

Frecvent Întrebat Întrebări
Here is a list of frequently asked questions about Circus:

Cum face Circ stivui comparaţie la a clasic stack?
In a classical WSGI stack, you have a server like Gunicorn that serves on a port or an
unix socket and is usually deployed behind a web server like Nginx: [image]

Clients call Nginx, which reverse proxies all the calls to Gunicorn.

If you want to make sure the Gunicorn process stays up and running, you have to use a
program like Supervisord or upstart.

Gunicorn in turn watches for its processes ("workers").

In other words you are using two levels of process managment. One that you manage and
control (supervisord), and a second one that you have to manage in a different UI, with a
different philosophy and less control over what's going on (the wsgi server's one)

This is true for Gunicorn and most multi-processes WSGI servers out there I know about.
uWsgi is a bit different as it offers plethoras of options.

But if you want to add a Redis server in your stack, you voi end up with managing your
stack processes in two different places.

Circus' approach on this is to manage processes și prize.

A Circus stack can look like this: [image]

So, like Gunicorn, Circus is able to bind a socket that will be proxied by Nginx. Circus
don't deal with the requests but simply binds the socket. It's then up to a web worker
process to accept connections on the socket and do the work.

It provides equivalent features than Supervisord but will also let you manage all
processes at the same level, wether they are web workers or Redis or whatever. Adding a
new web worker is done exactly like adding a new Redis process.

Bănci
We did a few benches to compare Circus & Chaussette with Gunicorn. To summarize, Circus is
not adding any overhead and you can pick up many different backends for your web workers.

A se vedea:

· http://blog.ziade.org/2012/06/28/wgsi-web-servers-bench

· http://blog.ziade.org/2012/07/03/wsgi-web-servers-bench-part-2

Cum la depanare Circus?
În mod implicit, circ keeps its logging to stdout rather sparse. This lack of output can
make things hard to troubleshoot when processes seem to be having trouble starting.

To increase the logging circ provides, try increasing the log level. To see the
available log levels just use the --Ajutor steag.

$ circus --log-level debug test.ini

One word of warning. If a process is flapping and the debug log level is turned on, you
will see messages for each start attempt. It might be helpful to configure the app that is
flapping to use a întârziere_încălzire to slow down the messages to a manageable pace.

[watcher:webapp]
cmd = python -m myapp.wsgi
întârziere_încălzire = 5

În mod implicit, stdout și stderr are captured by the circ process. If you are testing your
config and want to see the output in line with the circusd output, you can configure your
watcher to use the StdoutStream clasă.

[watcher:webapp]
cmd = python -m myapp.wsgi
stdout_stream.class = StdoutStream
stderr_stream.class = StdoutStream

If your application is producing a traceback or error when it is trying to start up you
should be able to see it in the output.

changelog istorie
0.12.1 - 2015-08-05
· Fix error when restarting a watcher with an output stream - #913

· Minor doc tweaks

0.12 - 2015-06-02
This release brings Python 3.4, Tornado 4 and Windows support, among several exciting
features and fixes.

The Windows support is still experimental, and does not handle streams.

Schimbari majore:

· Compatibility with Python 3.4 - #768

· Experimental Windows support - #788

· Compatibility with Tornado 4 - #872

· Revamped Debian packaging - #896 - #903

· Add support for Papa process kernel - #850

· Add globing and regex matching for starting, stopping and restarting watchers - #829 -
#902

Mai multe modificări:

· Optimization of the shutdown - #784 - #842

· Add possibility to specify virtualenv version for the watchers - #805

· Add --nostop option to the rmwatcher command - #777

· Add a callback to Arbiter.start - #840

· Fix reloading watchers with uppercase letters - #823

· Remove leaking socket in stats daemon - #843

· Fix multicast on SunOS - #876

· Close output streams when stopping a watcher - #885

· Fix signal sending to grandchildren with --recursive - #888

0.11.1 - 2014-05-22
· Fixed a regression that broke Circus on 2.6 - #782

0.11 - 2014-05-21
This release is not introducing a lot of features, and focused on making Circus more
robust & stable.

Major changes/fixes:

· Make sure we cannot execute two conflictings commands on the arbiter simultanously.

· we have 2 new streams class: TimedRotatingFileStream, WatchedFileStream

· we have one new hook: after_spawn hook

· CircusPlugin is easier to use

· fix autostart=False watchers during start (regression)

Mai multe modificări:

· circus messages can be routed to syslog now - #748

· endpoint_owner option added so we can define which user owns ipc socket files created by
circ.

· Started Windows support (just circusctl for now)

· fixed a lot of leaks in the tests

· Allow case sensitive environment variables

· The resource plugin now accepts absolute memory values - #609

· Add support to the add command for the 'singleton' option - #767

· Allow sending arbitrary signals to child procs via resource watcher - #756

· Allow INI/JSON/YAML configuration for logging

· Make sure we're compatible with psutil 2.x și 3.x

· Added more metrics to the statsd provider - #698

· Fixed multicast discovery - #731

· Make start, restart and reload more uniform - #673

· Correctly initialize all use groups - #635

· improved tests stability

· many, many more things....

0.10 - 2013-11-04
Schimbari majore:

· Now Python 3.2 & 3.3 compatible - #586

· Moved the core to a fully async model - #569

· Improved documentation - #622

Mai multe modificări:

· Added stop_signal & stop_children - #594

· Make sure the watchdog plugin closes the sockets - #588

· Switched to ZMQ JSON parser

· IN not supported on all platforms - #573

· Allow global environment substitutions in any config section - #560

· Allow dashes in sections names - #546

· Now variables are expanded everywhere in the config - #554

· Added the CommandReloader plugin

· Added before_signal & after_signal hooks

· Allow flapping plugin to retry indefinitely

· Don't respawn procs when the watcher is stopping - #529 - #536

· Added a unique id for each client message - #517

· worker ids are now "slots" -

· Fixed the graceful shutdown behavior - #515

· Make sure we can add watchers even if the arbiter is not started - #503

· Make sure make sure we pop expired process - #510

· Make sure the set command can set several hooks

· Correctly support ipv6 sockets - #507

· Allow custom options for stdout_stream and stderr_stream - #495

· Added time_format for FileStream - #493

· Added new socket config option to bind to a specific interface by name

0.9.3 - 2013-09-04
· Make sure we can add watchers even if the arbiter is not started

· Make sure we pop expired process

· Make sure the set command can set one or several hooks

· Correctly support ipv6 sockets and improvments of CircusSockets

· Give path default value to prevent UnboundLocalError

· Added a test for multicast_endpoint existence in Controller initialization

· Not converting every string of digits to ints anymore

· Add tests

· No need for special cases when converting stdout_stream options

· also accept umask as an argument for consistency

· Allow custom options for stdout_stream and stderr_stream.

· Add new socket config option to bind to a specific interface by name

· Add time_format for FileStream + tests

· Update circus.upstart

0.9.2 - 2013-07-17
· When a PYTHONPATH is defined in a config file, it's loaded in sys.path so hooks can be
located there - #477, #481

· Use a single argument for add_callback so it works with PyZMQ < 13.1.x - see #478

0.9 - 2013-07-16
· added [env] sections wildcards

· added global [env] secrtion

· fixed hidden exception when circus-web is not installed - #424

· make sure incr/decr commands really us the nb option - #421

· Fix watcher virtualenv site-packages not in PYTHONPATH

· make sure we dont try to remove more processes than 0 - #429

· updated bootstrap.py - #436

· fixed multiplatform separator in pythonpath virtualenv watcher

· refactored socket close function

· Ensure env sections are applied to all watchers - #437

· added the reloadconfig command

· added circus.green and removed gevent from the core - #441, #452

· silenced spurious stdout & warnings in the tests - #438

· $(circus.env.*) can be used for all options in the config now

· added a before_spawn hook

· correct the path of circusd in systemd service file - #450

· make sure we can change hooks and set streams via CLI - #455

· improved doc

· added a spawn_count stat in watcher

· added min_cpu and min_mem parameters in ResourceWatcher plugin

· added the FQDN information to the arbiter.

0.8.1 - 2013-05-28
· circusd-stats was choking on unix sockets - #415

· circusd-stats & circushttpd child processes stdout/stderr are now left open by default.
Python <= 2.7.5 would choke in the logging module in case the 2/3 fds were closed - #415

· Now redirecting to /dev/null in the child process instead of closing. #417

0.8 - 2013-05-24
· Integrated log handlers into zmq io loop.

· Make redirector restartable and subsequently more robust.

· Uses zmq.green.eventloop when gevent is detected

· Added support for CIRCUSCTL_ENDPOINT environment variable to circusctl - #396

· util: fix bug in to_uid function - #397

· Remove handler on ioloop error - #398.

· Improved test coverage

· Deprecated the 'service' option for the ResourceWatcher plugin - #404

· removed psutil.error usage

· Added UDP discovery in circusd - #407

· Now allowing globs at arbitrary directory levels - #388

· Added the 'statd' configuration option - #408

· Add pidfile, logoutput and loglevel option to circus configuration file - #379

· Added a tutorial in the docs.

· make sure we're merging all sections when using include - #414

· added pipe_stdout, pipe_stderr, close_child_stderr & close_child_stdout options to the
Process class

· added close_child_stderr & close_child_stdout options to the watcher

0.7.1 - 2013-05-02
· Fixed the respawn option - #382

· Make sure we use an int for the timeout - #380

· display the unix sockets as well - #381

· Make sure it works with the latest pyzmq

· introduced a second syntax for the fd notation

0.7 - 2013-04-08
· Fix get_arbiter example to use a dict for the watchers argument. #304

· Add some troubleshooting documentation #323

· Add python buildout support

· Removed the gevent and the thread redirectors. now using the ioloop - fixes #346.
Relates #340

· circus.web is now its own project

· removed the pyzmq patching

· Allow the watcher to be configured but not started #283

· Add an option to load a virtualenv site dir

· added on_demand watchers

· added doc about nginx+websockets #371

· now properly parsing the options list of each command #369

· Fixed circusd-stats events handling #372

· fixed the overflow issue in circus-top #378

· many more things...

0.6 - 2012-12-18
· Patching protocols name for sockets - #248

· Don't autoscale graphs. #240

· circusctl: add per command help, from docstrings #217

· Added workers hooks

· Added Debian package - #227

· Added Redis, HTTP Observer, Full stats & Resource plugins

· Now processes can have titles

· Added autocompletion

· Added process/watcher age in the webui

· Added SSH tunnel support

· Now using pyzmq.green

· Added upstart script & Varnish doc

· Added environment variables & sections

· Added unix sockets support

· Added the respawn option to have single-run watchers

· Now using tox in the tests

· Allow socket substitution in args

· New doc theme

· New rotation options for streams: max_bytes/backup_count

0.5.2 - 2012-07-26
· now patching the thread module from the stdlib to avoid some Python bugs - #203

· better looking circusctl help screen

· uses pustil get_nice() when available (nice was deprecated) - #208

· added max_age support - #221

· only call listen() on SOCK_STREAM or SOCK_SEQPACKET sockets

· make sure the controller empties the plugins list in update_watchers() - #220

· added --log-level and --log-output to circushttpd

· fix the process killing via the web UI - #219

· now circus is zc.buildout compatible for scripts.

· cleanup the websocket when the client disconnect - #225

· fixed the default value for the endpoint - #199

· splitted circushttpd in logical modules

0.5.1 - 2012-07-11
· Fixed a bunch of typos in the documentation

· Added the debug option

· Package web-requirements.txt properly

· Added a errno error code in the messages - fixes #111

0.5 - 2012-07-06
· added socket support

· added a listsocket command

· sockets have stats too !

· fixed a lot of small bugs

· removed the wid - now using pid everywhere

· faster tests

· changed the variables syntax

· use pyzmq's ioloop in more places

· now using iowait for all select() calls

· incr/decr commands now have an nbprocess parameter

· Add a reproduce_env option to watchers

· Add a new UNEXISTING status to the processes

· Added the global httpd option to run circushttpd as a watcher

0.4 - 2012-06-12
· Added a plugin system

· Added a "singleton" option for watchers

· Fixed circus-top screen flickering

· Removed threads from circus.stats in favor of zmq periodic callbacks

· Enhanced the documentation

· Circus client now have a send_message api

· The flapping feature is now a plugin

· Every command line tool have a --version option

· Added a statsd plugin (sends the events from circus to statsd)

· The web UI now uses websockets (via socketio) to get the stats

· The web UI now uses sessions for "flash messages" in the web ui

0.3.4 - 2012-05-30
· Fixed a race condition that prevented the controller to cleanly reap finished processes.

· Now check_flapping can be controlled in the configuration. And activated/deactivated
per watcher.

0.3.3 - 2012-05-29
· Fixed the regression on the uid handling

0.3.2 - 2012-05-24
· allows optional args property to add_watcher command.

· added circushttpd, circus-top and circusd-stats

· allowing Arbiter.add_watcher() to set all Watcher option

· make sure the redirectors are re-created on restarts

0.3.1 - 2012-04-18
· fix: make sure watcher' defaults aren't overrided

· added a StdoutStream class.

0.3 - 2012-04-18
· added the streaming feature

· now displaying coverage in the Sphinx doc

· fixed the way the processes are killed (no more SIGQUIT)

· the configuration has been factored out

· setproctitle support

0.2 - 2012-04-04
· Removed the Arăta name. replaced by Watcher.

· Added support for setting process rlimit.

· Added support for include dirs in the config file.

· Fixed a couple of leaking file descriptors.

· Fixed a core dump in the flapping

· Doc improvments

· Make sure circusd errors properly when another circusd is running on the same socket.

· get_arbiter now accepts several watchers.

· Fixed the cmd vs args vs executable in the process init.

· Fixed --start on circusctl add

0.1 - 2012-03-20
· initial release

om pagini
circ om pagină
sinopsis
circusd [opțiuni] [config]

Descriere
circul este procesul principal al arhitecturii circului. Are grijă de rularea tuturor
proceselor. Fiecare proces gestionat de Circus este un proces copil al circ.

Argumente
config Fișier de configurare

Opţiuni
-h, --Ajutor
Afișați mesajul de ajutor și ieșiți

--nivel-log NIVEL
Specificați nivelul de jurnal. NIVEL poate fi info, depana, critic, de avertizare or eroare.

--log-output LOGOUTPUT
Locația în care vor fi scrise jurnalele. Comportamentul implicit este să scrieți la
stdout (puteți forța trecând „-” acestei opțiuni). Ia un nume de fișier
in caz contrar.

--logger-config LOGGERCONFIG
Locația în care se află un fișier standard INI, JSON sau YAML de configurare a loggerului Python
poate fi găsit. Aceasta poate fi folosită pentru a suprascrie configurația implicită de logare pentru
arbitrul.

--daemon
Începe circul în fundal.

--pidfile PIDFILE
Locația fișierului PID.

--versiune
Afișează versiunea Circus și iese.

Vedea de asemenea
circ (1), circ (1), circ-stats (1), circ-plugin (1), blatul de circ (1).

Full Documentation is available at http://circus.readthedocs.org

circ om pagină
sinopsis
circusctl [opțiuni] comandă [args]

Descriere
circusctl este front end pentru a controla demonul Circus. Este conceput pentru a ajuta
administrator controlează funcționarea Circudului circ demonul.

Comenzi
adăuga Adăugați un observator

decr Reduceți numărul de procese dintr-un observator

dstats Obțineți statistici de circ

obține Obțineți valoarea anumitor opțiuni de urmărire

opțiuni globale
Obțineți opțiunile de arbitru

incr Creșteți numărul de procese dintr-un monitor

piton
Creați shell în procesul de circ

listă Obțineți o listă de observatori sau procese dintr-un observator

asculta Abonați-vă la un eveniment urmăritor

listsocket-uri
Obțineți lista de prize

numprocese
Obțineți numărul de procese

numwatchers
Obțineți numărul de observatori

Opțiuni
Obțineți valoarea tuturor opțiunilor pentru un observator

părăsi Renunță imediat la arbitru

reincarca Reîncărcați arbitrul sau un observator

reloadconfig
Reîncărcați fișierul de configurare

reîncepe
Reporniți arbitrul sau observatorul

rm Eliminați un observator

set Setați o opțiune de observator

semnal Trimite un semnal

Începe Porniți arbitrul sau un observator

Statistici Obțineți informații despre proces

Starea Obțineți statutul unui observator sau al tuturor observatorilor

opri Opritori

Opţiuni
--punct final ENDPOINT
punctul final al conexiunii

-h, --Ajutor
Afișați mesajul de ajutor și ieșiți

--json ieșire în JSON

--frumoasa
ieșire frumoasă

--ssh SSH
Server SSH în format utilizator@gazdă:port

--ssh_keyfile SSH_KEYFILE
calea către fișierul cheie pentru a autoriza utilizatorul

--pauză PAUZĂ
expirare a conexiunii

--versiune
Afișează versiunea Circus și iese.

Vedea De asemenea
circ (1), circ (1), circ-stats (1), circ-plugin (1), blatul de circ (1).

Full Documentation is available at http://circus.readthedocs.org

circ-plugin om pagină
sinopsis
circus-plugin [opțiuni] [plugin]

Descriere
circus-plugin permite lansarea unui plugin de la un daemon Circus care rulează.

Argumente
conecteaza Numele complet calificat al clasei de plugin.

Opţiuni
--punct final ENDPOINT
Punct final de conectare.

--pubsub PUBSUB
Priza pub/sub circusd ZeroMQ la care să se conecteze.

--config ÎNFIINȚAT
Fișierul de configurare a pluginului.

--verificare-întârziere CHECK_DELAY
Verificați întârzierea.

--nivel-log NIVEL
Specificați nivelul de jurnal. NIVEL poate fi info, depana, critic, de avertizare or eroare.

--log-output LOGOUTPUT
Locația în care vor fi scrise jurnalele. Comportamentul implicit este să scrieți la
stdout (puteți forța trecând „-” acestei opțiuni). Ia un nume de fișier
in caz contrar.

--ssh SSH
Server SSH în format utilizator@gazdă:port.

-h, --Ajutor
Afișați mesajul de ajutor și ieșiți.

--versiune
Afișează versiunea Circus și iese.

Vedea de asemenea
circ (1), circ (1), circ (1), circ-stats (1), blatul de circ (1).

Full Documentation is available at http://circus.readthedocs.org

blatul de circ om pagină
sinopsis
circ-top [opțiuni]

Descriere
circ-top este a top-comandă similară pentru afișarea demonului Circus și a proceselor gestionate de
circ.

Opţiuni
--punct final ENDPOINT
Punct final de conectare.

--ssh SSH
Server SSH în format utilizator@gazdă:port.

--proces-timeout PROCESS_TIMEOUT
După această întârziere de inactivitate, un proces va fi eliminat.

-h, --Ajutor
Afișați mesajul de ajutor și ieșiți.

--versiune
Afișează versiunea Circus și iese.

Vedea de asemenea
circ (1), circ (1), circ (1), circ-stats (1), circ-plugin (1).

Full Documentation is available at http://circus.readthedocs.org

circ-stats om pagină
sinopsis
circusd-stats [opțiuni]

Descriere
circusd-stats rulează agregatorul de statistici pentru Circus.

Opţiuni
--punct final ENDPOINT
Punct final de conectare.

--pubsub PUBSUB
Priza pub/sub circusd ZeroMQ la care să se conecteze.

--statspoint STATSPOINT
Soclul pub/sub ZeroMQ către care trimiteți date.

--nivel-log NIVEL
Specificați nivelul de jurnal. NIVEL poate fi info, depana, critic, de avertizare or eroare.

--log-output LOGOUTPUT
Locația în care vor fi scrise jurnalele. Comportamentul implicit este să scrieți la
stdout (puteți forța trecând „-” acestei opțiuni). Ia un nume de fișier
in caz contrar.

--ssh SSH
Server SSH în format utilizator@gazdă:port.

-h, --Ajutor
Afișați mesajul de ajutor și ieșiți.

--versiune
Afișează versiunea Circus și iese.

Vedea de asemenea
circ (1), circ (1), circ (1), circ-plugin (1), blatul de circ (1).

Full Documentation is available at http://circus.readthedocs.org

Glosar: Circus-specific termeni
arbitru
arbitru is responsible for managing all the watchers within circus, ensuring
all processes run correctly.

controlor
A controlor contains the set of actions that can be performed on the arbiter.

flapping
flapping detectare subscribes to events and detects when some processes are
constantly restarting.

pub/sub
Circus has a pubsub that receives events from the watchers and dispatches them to
all subscribers.

la distanta controlor
la distanta controlor allows you to communicate with the controller via ZMQ to
control Circus.

watcher, observatorii
A Watcher is the program you tell Circus to run. A single Circus instance can run
one or more watchers.

muncitor, muncitorii, proces, procese
A proces is an independent OS process instance of your program. A single watcher
can run one or more processes. We also call them workers.

Drepturi de autor
Circus was initiated by Tarek Ziade and is licenced under APLv2

Benoit Chesneau was an early contributor and did many things, like most of the
circus.commands work.

licență
Copyright 2012 - Mozilla Foundation
Copyright 2012 - Benoit Chesneau

Licențiat sub licența Apache, versiunea 2.0 („Licența”);
nu puteți utiliza acest fișier decât în ​​conformitate cu licența.
Puteți obține o copie a Licenței la adresa

http://www.apache.org/licenses/LICENSE-2.0

Cu excepția cazului în care este cerut de legea aplicabilă sau convenit în scris, software
distribuite sub licență sunt distribuite pe o bază „CA ATARE”,
FĂRĂ GARANȚII SAU CONDIȚII DE ORICE TIP, fie expresă, fie implicită.
Consultați licența pentru limba specifică care reglementează permisiunile și
limitări conform licenței.

Contribuitori
Vedeți lista completă la https://github.com/circus-tent/circus/blob/master/CONTRIBUTORS.txt

Use circus online using onworks.net services


Servere și stații de lucru gratuite

Descărcați aplicații Windows și Linux

  • 1
    turkdevops
    turkdevops
    TurkDevOps a ?k kaynak yaz?l?m
    geli?tirici topluluklar? Echipa DevTurks
    Taraf?ndan desteklenmektedir..
    Caracteristici:https://github.com/turkdevopshttps://turkdevops.g...
    Descărcați turkdevops
  • 2
    asammdf
    asammdf
    *asammdf* este un parser rapid Python și
    redactor pentru ASAM (Asociația pentru
    Standardizarea automatizării și
    Sisteme de măsurare) MDF / MF4
    (Format de date de măsurare...
    Descărcați asammdf
  • 3
    LAME (Lame nu este un codificator MP3)
    LAME (Lame nu este un codificator MP3)
    LAME este un instrument educațional de utilizat
    pentru a afla despre codificarea MP3. The
    Scopul proiectului LAME este îmbunătățirea
    psihoacustica, calitatea si viteza
    de deputat...
    Descărcați LAME (Lame Aint an MP3 Encoder)
  • 4
    wxPython
    wxPython
    Un set de module de extensie Python care
    împachetați clasele GUI multiplatformă din
    wxWidgets.. Public: Dezvoltatori. Utilizator
    interfață: X Window System (X11), Win32...
    Descărcați wxPython
  • 5
    packfilemanager
    packfilemanager
    Acesta este managerul de fișiere al pachetului Total War
    proiect, începând cu versiunea 1.7. A
    scurtă introducere în Warscape
    modding:...
    Descărcați packfilemanager
  • 6
    IPerf2
    IPerf2
    Un instrument de măsurare a traficului de rețea
    Performanță TCP și UDP cu metrici
    atât în ​​jurul debitului cât și al latenței. The
    obiectivele includ menținerea unui activ
    cod iperf...
    Descărcați IPerf2
  • Mai mult »

Comenzi Linux

Ad