|
System | : | Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686 |
Software | : | Apache. PHP/5.3.6-13ubuntu3.10 |
ID | : | uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
|
|
Safe Mode | : | OFF |
Open_Basedir | : | OFF |
Freespace | : | 23.57 GB of 70.42 GB (33.47%) |
|
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON |
Disabled Functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
|
[ System Info ]
[ Processes ]
[ SQL Manager ]
[ Eval ]
[ Encoder ]
[ Mailer ]
[ Back Connection ]
[ Backdoor Server ]
[ Kernel Exploit Search ]
[ MD5 Decrypter ]
[ Reverse IP ]
[ Kill Shell ]
[ FTP Brute-Force ]
|
|
/
usr/
lib/
python2.7/
dist-packages/
landscape/
- drwxr-xr-x
|
Viewing file: service.py (3.47 KB) -rw-r--r--Select action/file-type:  ( +) |  ( +) |  ( +) | Code ( +) | Session ( +) |  ( +) | SDB ( +) |  ( +) |  ( +) |  ( +) |  ( +) |  ( +) |
import os import logging import signal
from twisted.application.service import Application, Service from twisted.application.app import startApplication
from landscape.log import rotate_logs from landscape.reactor import TwistedReactor from landscape.deployment import get_versioned_persist, init_logging
class LandscapeService(Service, object): """Utility superclass for defining Landscape services.
This sets up the reactor and L{Persist} object.
@cvar service_name: The lower-case name of the service. This is used to generate the bpickle and the Unix socket filenames. @ivar config: A L{Configuration} object. @ivar reactor: A L{TwistedReactor} object. @ivar persist: A L{Persist} object, if C{persist_filename} is defined. @ivar factory: A L{LandscapeComponentProtocolFactory}, it must be provided by instances of sub-classes. """ reactor_factory = TwistedReactor persist_filename = None
def __init__(self, config): self.config = config try: from landscape.lib import bpickle_dbus except ImportError: pass else: bpickle_dbus.install() self.reactor = self.reactor_factory() if self.persist_filename: self.persist = get_versioned_persist(self) if not (self.config is not None and self.config.ignore_sigusr1): signal.signal(signal.SIGUSR1, lambda signal, frame: rotate_logs()) self.socket = os.path.join(self.config.sockets_path, self.service_name + ".sock")
def startService(self): Service.startService(self) logging.info("%s started with config %s" % ( self.service_name.capitalize(), self.config.get_config_filename())) self.port = self.reactor.listen_unix(self.socket, self.factory)
def stopService(self): # We don't need to call port.stopListening(), because the reactor # shutdown sequence will do that for us. Service.stopService(self) logging.info("%s stopped with config %s" % ( self.service_name.capitalize(), self.config.get_config_filename()))
def run_landscape_service(configuration_class, service_class, args): """Run a Landscape service.
This function instantiates the specified L{LandscapeService} subclass and attaches the resulting service object to a Twisted C{Application}. After that it starts the Twisted L{Application} and calls the L{TwistedReactor.run} method of the L{LandscapeService}'s reactor.
@param configuration_class: The service-specific subclass of L{Configuration} used to parse C{args} and build the C{service_class} object. @param service_class: The L{LandscapeService} subclass to create and start. @param args: Command line arguments used to initialize the configuration. """ # Let's consider adding this: # from twisted.python.log import ( # startLoggingWithObserver, PythonLoggingObserver) # startLoggingWithObserver(PythonLoggingObserver().emit, setStdout=False)
configuration = configuration_class() configuration.load(args) init_logging(configuration, service_class.service_name) application = Application("landscape-%s" % (service_class.service_name,)) service = service_class(configuration) service.setServiceParent(application) startApplication(application, False)
if configuration.ignore_sigint: signal.signal(signal.SIGINT, signal.SIG_IGN)
service.reactor.run()
|