File: run-graphite-devel-server.py

package info (click to toggle)
graphite-web 1.1.4-3%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,416 kB
  • sloc: python: 11,275; sh: 61; makefile: 53
file content (46 lines) | stat: -rwxr-xr-x 1,352 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python

import sys, os
from optparse import OptionParser

from django.core import management

option_parser = OptionParser(usage='''
%prog [options] GRAPHITE_ROOT
''')
option_parser.add_option('--port', default=8080, action='store', type=int, help='Port to listen on')
option_parser.add_option('--interface', default='0.0.0.0', action='store', help='Interface to listen on')
option_parser.add_option('--libs', default=None, help='Path to the directory containing the graphite python package')
option_parser.add_option('--noreload', action='store_true', help='Disable monitoring for changes')

(options, args) = option_parser.parse_args()

if not args:
  option_parser.print_usage()
  sys.exit(1)

graphite_root = args[0]

python_path = os.path.join(graphite_root, 'webapp')

if options.libs:
  libdir = os.path.expanduser(options.libs)
  print('Adding %s to your PYTHONPATH' % libdir)
  os.environ['PYTHONPATH'] = libdir + ':' + os.environ.get('PYTHONPATH','')

print("Running Graphite from %s under django development server\n" % graphite_root)

command = [
  'django-admin.py',
  'runserver',
  '--pythonpath', python_path,
  '--settings', 'graphite.settings',
  '%s:%d' % (options.interface, options.port)
]

if options.noreload:
  command.append('--noreload')

print(' '.join(command))

management.execute_from_command_line(command)