Example #1
0
def main(_executable=sys.argv[0], _sys_path=sys.path):
    """The entry point of this module."""
    bg_utils.manipulate_paths_like_upstream(_executable, _sys_path)
    from carbon import util as carbon_util
    from carbon import exceptions as carbon_exceptions

    # Importing the plugin registers it.
    from biggraphite.plugins import carbon as unused_carbon  # noqa

    try:
        # The carbon code tries to guess GRAPHITE_ROOT from the filename
        # given to run_twistd_plugin() to set GRAPHITE_ROOT. This is then
        # used to setup default paths. Try to make it somewhat compatible
        # when carbon is installed in its default directory.
        bg_utils.setup_graphite_root_path(carbon_util.__file__)
        carbon_util.run_twistd_plugin("carbon-cache")
    except carbon_exceptions.CarbonConfigException as exc:
        # This is what carbon cache does, we preserve that behaviour.
        raise SystemExit(str(exc))
Example #2
0
 def test_setup_graphite_root_path(self):
     bg_utils.setup_graphite_root_path("/fake/path/to/carbon/file")
     assert "GRAPHITE_ROOT" not in os.environ
     bg_utils.setup_graphite_root_path("/opt/graphite/lib/carbon/file")
     assert "GRAPHITE_ROOT" in os.environ
     self.assertEqual(os.environ["GRAPHITE_ROOT"], "/opt/graphite")