예제 #1
0
    def start(self):
        log.debug("Starting Carbon..")

        twistd_options = ["--no_save", "--nodaemon", 'carbon-combined']

        if self.carbon_config_file is not None:
            twistd_options.append('--config=' + self.carbon_config_file)

        config = ServerOptions()
        config.parseOptions(twistd_options)
        config.subCommand = 'carbon-combined'

        # Hacky stuff to get carbon logging to the proper place
        from carbon.conf import settings as c_sett
        from carbon import log as c_log

        log_dir = os.path.join(os.environ['GRAPHITE_ROOT'], 'storage', 'log','carbon')
        if not os.path.exists(log_dir):
            os.makedirs(log_dir)

        c_log.logToStdout()
        c_log.logToDir(log_dir)

        # Change these if you want big logs
        c_sett.LOG_UPDATES = False
        c_sett.LOG_CACHE_HITS = True



        plg = config.loadedPlugins[config.subCommand]
        self.application_service = plg.makeService(config.subOptions)

        if reactor.running:
            raise Exception('Reactor is already running.')

        self.application_service.startService()
        self.reactor_thread = self.ReactorThread()
        self.reactor_thread.start()

        log.debug("Started Carbon.")
예제 #2
0
    def start(self):
        log.debug("Starting Carbon..")

        twistd_options = ["--no_save", "--nodaemon", 'carbon-combined']

        if self.carbon_config_file is not None:
            twistd_options.append('--config=' + self.carbon_config_file)

        config = ServerOptions()
        config.parseOptions(twistd_options)
        config.subCommand = 'carbon-combined'

        # Hacky stuff to get carbon logging to the proper place
        from carbon.conf import settings as c_sett
        from carbon import log as c_log

        log_dir = os.path.join(os.environ['GRAPHITE_ROOT'], 'storage', 'log',
                               'carbon')
        if not os.path.exists(log_dir):
            os.makedirs(log_dir)

        c_log.logToStdout()
        c_log.logToDir(log_dir)

        # Change these if you want big logs
        c_sett.LOG_UPDATES = False
        c_sett.LOG_CACHE_HITS = True

        plg = config.loadedPlugins[config.subCommand]
        self.application_service = plg.makeService(config.subOptions)

        if reactor.running:
            raise Exception('Reactor is already running.')

        self.application_service.startService()
        self.reactor_thread = self.ReactorThread()
        self.reactor_thread.start()

        log.debug("Started Carbon.")
예제 #3
0
def main():
    parser = OptionParser()
    parser.add_option("-t", "--host", dest="host",
                      help="host name", metavar="HOST", default="localhost")

    parser.add_option("-p", "--port", dest="port", type=int,
                      help="port number", metavar="PORT",
                      default=5672)

    parser.add_option("-u", "--user", dest="username",
                      help="username", metavar="USERNAME",
                      default="guest")

    parser.add_option("-w", "--password", dest="password",
                      help="password", metavar="PASSWORD",
                      default="guest")

    parser.add_option("-V", "--vhost", dest="vhost",
                      help="vhost", metavar="VHOST",
                      default="/")

    parser.add_option("-e", "--exchange", dest="exchange",
                      help="exchange", metavar="EXCHANGE",
                      default="graphite")

    parser.add_option("-v", "--verbose", dest="verbose",
                      help="verbose",
                      default=False, action="store_true")

    (options, args) = parser.parse_args()


    log.logToStdout()
    startReceiver(options.host, options.port, options.username,
                  options.password, vhost=options.vhost,
                  exchange_name=options.exchange, verbose=options.verbose)
    reactor.run()
예제 #4
0
    print("  relay")
    raise SystemExit(1)

destinations = []
for arg in args:
    parts = arg.split(':', 2)
    host = parts[0]
    port = int(parts[1])
    if len(parts) > 2:
        instance = parts[2]
    else:
        instance = None
    destinations.append((host, port, instance))

if options.debug:
    log.logToStdout()
    log.setDebugEnabled(True)
    defer.setDebugging(True)

if options.routing == 'consistent-hashing':
    router = ConsistentHashingRouter(options.replication,
                                     diverse_replicas=options.diverse_replicas)
elif options.routing == 'relay':
    if exists(options.relayrules):
        router = RelayRulesRouter(options.relayrules)
    else:
        print("relay rules file %s does not exist" % options.relayrules)
        raise SystemExit(1)

client_manager = CarbonClientManager(router)
reactor.callWhenRunning(client_manager.startService)
예제 #5
0
    if exists("/proc/%d" % pid):
        print "%s is running with pid %d" % (program, pid)
        raise SystemExit(0)
    else:
        print "%s is not running" % program
        raise SystemExit(0)


# Read config (we want failures to occur before daemonizing)
settings.readFrom(options.config, "cache")


# --debug
if options.debug:
    logToStdout()
else:
    if not isdir(options.logdir):
        os.makedirs(options.logdir)

    from carbon.util import daemonize, dropprivs

    daemonize()
    logToDir(options.logdir)

    pidfile = open(options.pidfile, "w")
    pidfile.write(str(os.getpid()))
    pidfile.close()

    def shutdown():
        if os.path.exists(options.pidfile):
예제 #6
0
def main():
    parser = OptionParser()
    parser.add_option("-t",
                      "--host",
                      dest="host",
                      help="host name",
                      metavar="HOST",
                      default="localhost")

    parser.add_option("-p",
                      "--port",
                      dest="port",
                      type=int,
                      help="port number",
                      metavar="PORT",
                      default=5672)

    parser.add_option("-u",
                      "--user",
                      dest="username",
                      help="username",
                      metavar="USERNAME",
                      default="guest")

    parser.add_option("-w",
                      "--password",
                      dest="password",
                      help="password",
                      metavar="PASSWORD",
                      default="guest")

    parser.add_option("-V",
                      "--vhost",
                      dest="vhost",
                      help="vhost",
                      metavar="VHOST",
                      default="/")

    parser.add_option("-e",
                      "--exchange",
                      dest="exchange",
                      help="exchange",
                      metavar="EXCHANGE",
                      default="graphite")

    parser.add_option("-v",
                      "--verbose",
                      dest="verbose",
                      help="verbose",
                      default=False,
                      action="store_true")

    (options, args) = parser.parse_args()

    log.logToStdout()
    startReceiver(options.host,
                  options.port,
                  options.username,
                  options.password,
                  vhost=options.vhost,
                  exchange_name=options.exchange,
                  verbose=options.verbose)
    reactor.run()