예제 #1
0
    def runfs(self):
        usage = """
    Logagg Log collection FUSE filesystem

    """ + Fuse.fusage
        #argument parsing
        server = LogaggFS(version="%prog " + fuse.__version__,
                     usage=usage,
                     dash_s_do='setsingle',
                     file_class=LogaggFSFile)
        self.fuse_server = server

        p = server.parser
        p.add_option(mountopt='root', metavar='PATH',
                                 help='mountpoint')
        p.add_option(mountopt='loglevel', metavar='DEBUG/INFO' ,default='INFO',
                                help='level of logger')
        p.add_option(mountopt='logfile', metavar='PATH', default='/tmp/fuse.log',
                                help='file path to store logs')

        server.parse(values=server, errex=1)
        self.opts, self.args = server.parser.parse_args()

        #initiating logger
        self.log = DUMMY_LOG
        if self.opts.logfile:
            self.log = init_logger(fpath=self.opts.logfile,
                                level=self.opts.loglevel)

        ldir = os.path.abspath(server.root)
        ldir = os.path.join(ldir, '')[:-1]
        self.log_cache_dir = ldir

        server.log_cache_dir = self.log_cache_dir
        LogaggFSFile.log_cache_dir = self.log_cache_dir

        server.log = self.log
        MirrorFSFile.log = self.log

        self.log.debug('starting_up')
        #FIXME: report bug of init_logger not working with fpath=None
        try:
            if server.fuse_args.mount_expected():
                os.chdir(server.log_cache_dir)
        except OSError:
            log.exception("cannot_enter_root_of_underlying_filesystem", file=sys.stderr)
            sys.exit(1)

        # mkdir logs directory and state file inside log cache directory
        self.log_dir = self._mkdir_logdir(parent_directory=self.log_cache_dir)
        self.state_file = self._touch_statefile(parent_directory=self.log_cache_dir)

        # create tracklist for monitoring log files
        tracklist = TrackList(state_file=self.state_file,
                        directory=self.log_dir,
                        log=self.log)
        LogaggFSFile.tracklist = tracklist
        LogaggFSFile.mountpoint = server.fuse_args.mountpoint

        server.main()
예제 #2
0
    },
]

# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = '/var/www/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

LOG = init_logger(fmt=None,
                  quiet=False,
                  fpath='/var/log/uploadcsv.log',
                  level='INFO',
                  pre_hooks=[],
                  post_hooks=[],
                  metric_grouping_interval=1)
예제 #3
0
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '(@44m*70ipxapv2lt7lzzy50ycf*5mt$r9fyv1+od3nf3@tq2s'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['localhost', '159.69.205.72']

LOG = init_logger(fmt=None,
                  quiet=False,
                  level='INFO',
                  pre_hooks=[],
                  post_hooks=[],
                  metric_grouping_interval=1)

# Application definition

INSTALLED_APPS = [
    # djnago apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # 3rd party apps
    'reversion',
예제 #4
0
    def runfs(self):
        usage = ("""
        Logagg Log collection FUSE filesystem
        """ + Fuse.fusage)
        # Argument parsing
        server = LogaggFS(
            version="%prog " + fuse.__version__,
            usage=usage,
            dash_s_do="setsingle",
            file_class=LogaggFSFile,
        )
        self.fuse_server = server

        p = server.parser
        p.add_option(mountopt="root", metavar="PATH", help="mountpoint")
        p.add_option(
            mountopt="loglevel",
            metavar="DEBUG/INFO",
            default="INFO",
            help="level of logger",
        )
        p.add_option(
            mountopt="logfile",
            metavar="PATH",
            default="/tmp/fuse.log",
            help="file path to store logs",
        )

        server.parse(values=server, errex=1)
        self.opts, self.args = server.parser.parse_args()

        # initiating logger
        self.log = DUMMY_LOG
        if self.opts.logfile:
            self.log = init_logger(fpath=self.opts.logfile,
                                   level=self.opts.loglevel)

        if not hasattr(server, "root"):
            sys.exit(0)
        ldir = os.path.abspath(server.root)
        ldir = os.path.join(ldir, "")[:-1]
        self.log_cache_dir = ldir

        server.log_cache_dir = self.log_cache_dir
        LogaggFSFile.log_cache_dir = self.log_cache_dir

        server.log = self.log
        MirrorFSFile.log = self.log

        self.log.debug("starting_up")
        # FIXME: report bug of init_logger not working with fpath=None
        try:
            if server.fuse_args.mount_expected():
                os.chdir(server.log_cache_dir)
        except OSError:
            log.exception("cannot_enter_root_of_underlying_filesystem",
                          file=sys.stderr)
            sys.exit(1)

        # mkdir logs directory and state file inside log cache directory
        self.log_dir = self._mkdir_logdir(parent_directory=self.log_cache_dir)
        self.state_file = self._touch_statefile(
            parent_directory=self.log_cache_dir)

        # Create tracklist for monitoring log files
        tracklist = TrackList(state_file=self.state_file,
                              directory=self.log_dir,
                              log=self.log)
        LogaggFSFile.tracklist = tracklist

        # LRU cache that expires in TRACKFILES_REFRESH_INTERVAL sec(s)
        clock = ExpiringCache(1,
                              default_timeout=self.TRACKFILES_REFRESH_INTERVAL)
        clock.put("timeout", "no")
        LogaggFSFile.clock = clock

        LogaggFSFile.mountpoint = server.fuse_args.mountpoint

        server.main()
예제 #5
0
from django.conf.urls import url

from . import views
from basescript import init_logger
from kwikapi.django import RequestHandler

from food_delivery.settings import LOG_FILE_PATH

log = init_logger(fpath=LOG_FILE_PATH, fmt="json", level="INFO")

urlpatterns = [
    url(r'api/',
        RequestHandler(views.api, log=log).handle_request),
]