Glances --export-influxdb starts webserver (#1038)

This commit is contained in:
nicolargo 2017-02-20 17:51:53 +01:00
parent 88a6091a96
commit 9cee73212a
4 changed files with 41 additions and 20 deletions

5
NEWS
View File

@ -2,18 +2,19 @@
Glances Version 2
==============================================================================
Version 2.x
Version 2.8.3
=============
Enhancements and new features:
* Use new sensors-related APIs of Psutil 5.1.0 (issue #1018)
=> Remove Py3Sensors and Batinfo dependencies
* Add a "Cloud" plugin to grab stats inside the AWS EC2 API (issue #1029)
* Add a "Cloud" plugin to grab stats inside the AWS EC2 API (issue #1029)
Bugs corrected:
* Unable to launch Glances on Windows (issue #1021)
* Glances --export-influxdb starts Webserver (issue #1038)
Version 2.8.2
=============

View File

@ -70,11 +70,11 @@ def __signal_handler(signal, frame):
def end():
"""Stop Glances."""
if core.is_standalone() and not WINDOWS:
if core.is_standalone():
# Stop the standalone (CLI)
standalone.end()
logger.info("Stop Glances (with CTRL-C)")
elif core.is_client() and not WINDOWS:
elif core.is_client():
# Stop the client
client.end()
logger.info("Stop Glances client (with CTRL-C)")
@ -82,7 +82,7 @@ def end():
# Stop the server
server.end()
logger.info("Stop Glances server (with CTRL-C)")
elif core.is_webserver() or (core.is_standalone() and WINDOWS):
elif core.is_webserver() or core.is_standalone():
# Stop the Web server
webserver.end()
logger.info("Stop Glances web server(with CTRL-C)")
@ -221,7 +221,7 @@ def main():
signal.signal(signal.SIGINT, __signal_handler)
# Glances can be ran in standalone, client or server mode
if core.is_standalone() and not WINDOWS:
if core.is_standalone():
start_standalone(config=config, args=args)
elif core.is_client() and not WINDOWS:
if core.is_client_browser():
@ -230,9 +230,9 @@ def main():
start_client(config=config, args=args)
elif core.is_server():
start_server(config=config, args=args)
elif core.is_webserver() or (core.is_standalone() and WINDOWS):
elif core.is_webserver():
# Web server mode replace the standalone mode on Windows OS
# In this case, try to start the web browser mode automaticaly
if core.is_standalone() and WINDOWS:
if WINDOWS:
args.open_web_browser = True
start_webserver(config=config, args=args)

View File

@ -42,7 +42,6 @@ def user_config_dir():
path = os.path.expanduser('~/Library/Application Support')
else:
path = os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config')
path = os.path.join(path, 'glances')
return path
@ -54,7 +53,7 @@ def user_cache_dir():
- macOS: ~/Library/Caches/glances
- Windows: %LOCALAPPDATA%\glances\cache
"""
if WINDOWS:
if WINDOWS and os.environ.get('LOCALAPPDATA') is not None:
path = os.path.join(os.environ.get('LOCALAPPDATA'), 'glances', 'cache')
elif MACOS:
path = os.path.expanduser('~/Library/Caches/glances')
@ -78,7 +77,6 @@ def system_config_dir():
path = '/usr/local/etc'
else:
path = os.environ.get('APPDATA')
path = os.path.join(path, 'glances')
return path
@ -120,8 +118,10 @@ class Config(object):
if self.config_dir:
paths.append(self.config_dir)
paths.append(os.path.join(user_config_dir(), self.config_filename))
paths.append(os.path.join(system_config_dir(), self.config_filename))
if user_config_dir() is not None:
paths.append(os.path.join(user_config_dir(), self.config_filename))
if system_config_dir() is not None:
paths.append(os.path.join(system_config_dir(), self.config_filename))
return paths

View File

@ -282,6 +282,10 @@ Start the client browser (browser mode):\n\
if args.disable_autodiscover:
logger.info("Auto discover mode is disabled")
# By default Windows is started in Web mode
if WINDOWS:
args.webserver = True
# In web server mode
if args.webserver:
args.process_short_name = True
@ -365,13 +369,22 @@ Start the client browser (browser mode):\n\
args.export_opentsdb or \
args.export_rabbitmq or \
args.export_couchdb
if not (self.is_standalone() or self.is_client()) and export_tag:
if WINDOWS and export_tag:
# On Windows, export is possible but only in quiet mode
# See issue #1038
logger.info(
"On Windows OS, export disable the Web Interface")
self.args.quiet = True
self.args.webserver = False
elif not (self.is_standalone() or self.is_client()) \
and export_tag:
logger.critical(
"Export is only available in standalone or client mode")
sys.exit(2)
# Filter is only available in standalone mode
if args.process_filter is not None and not self.is_standalone():
if args.process_filter is not None \
and not self.is_standalone():
logger.critical(
"Process filter is only available in standalone mode")
sys.exit(2)
@ -414,23 +427,30 @@ Start the client browser (browser mode):\n\
def is_standalone(self):
"""Return True if Glances is running in standalone mode."""
return not self.args.client and not self.args.browser and not self.args.server and not self.args.webserver
return not self.args.client \
and not self.args.browser \
and not self.args.server \
and not self.args.webserver
def is_client(self):
"""Return True if Glances is running in client mode."""
return (self.args.client or self.args.browser) and not self.args.server
return (self.args.client or self.args.browser) \
and not self.args.server
def is_client_browser(self):
"""Return True if Glances is running in client browser mode."""
return self.args.browser and not self.args.server
return self.args.browser \
and not self.args.server
def is_server(self):
"""Return True if Glances is running in server mode."""
return not self.args.client and self.args.server
return not self.args.client \
and self.args.server
def is_webserver(self):
"""Return True if Glances is running in Web server mode."""
return not self.args.client and self.args.webserver
return not self.args.client \
and self.args.webserver
def get_config(self):
"""Return configuration file object."""