2008³â 07¿ù 13ÀÏ

twisted application ½ºÄÌ·¹Åæ ÄÚµå

Posted in Diary at 20:24:52 by ´ÙÁñ¸µ

twistd ·Î µµ´Â°Ç Á» Çü½ÄÀ» ¸ÂÃçÁà¾ßÇÏ°í ¼³Á¤ÀÌ ¼¶¼¼ÇÏ°Ô ºÒ°¡´ÉÇØ¼­ »ì¦ °íÃļ­ ÇÏ´ÂÁß

chdir(’/home/me2′)

from twisted.application import app
from twisted.python import log , logfile
from twisted.scripts._twistd_unix import UnixApplicationRunner

config = app.ServerOptions()
t = {’profile’: None, ‘uid’: None, ‘python’: None, ‘encrypted’: 0, ’syslog’: 0, ‘prefix’: ‘twisted’, ‘report-profile’: None, ‘euid’: 0,  ‘originalname’: 0, ‘rundir’: ‘/home/me2′, ‘logfile’: None, ‘nodaemon’: 0, ‘xml’: None, ‘chroot’: None, ‘no_save’: 0, ‘quiet’: 0, ‘profiler’: ‘hotshot’, ’source’: ‘zabbix_proxy.py’, ‘nothotshot’: 0, ‘gid’: None, ’savestats’: 0, ‘debug’: False, ‘pidfile’: ‘zabbix_proxy.pid’,'originalName’:'zabbix_proxy’}
for x in t:
if not config.has_key(x):
config[x] = t[x]
class ZabbixRunner(UnixApplicationRunner):
def createOrGetApplication(self):
return application
def getLogObserver(self):
logFile =  logfile.LogFile.fromFullPath(’zabbix_proxy.log’,rotateLength=100000000,maxRotatedFiles=3)
observer = log.FileLogObserver(logFile).emit
return observer

ZabbixRunner(config).run()
ÀÌ°Ç ¾ÖÇø®ÄÉÀÌ¼Ç ½ºÄÌ·¹Åæ ÄÚµå

from twisted.application import app , service
from twisted.application.service import Service
class LogWatcher(Service):
pass
logwatcher = LogWatcher()
application = service.Application(’me2day_logwatcher’, uid=0, gid=0)
logwatcher.setServiceParent(service.IServiceCollection(application))

Leave a Comment

Don't write Name and comment in english
I'll not accept only english comment
if you want to write in english
add "@" before your name like.. @KwonHanBae