__init__.py 1.9 KB
Newer Older
N
Nicolas Hennion 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Glances - An eye on your system
#
# Copyright (C) 2014 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .core.glances_core import GlancesCore

def main(argv=None):
N
Nicolas Hennion 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    # Create the Glances core instance
    core = GlancesCore()

    # Glances can be ran in standalone, client or server mode
    if (core.is_standalone()):
        # !!!
        print "Standalone mode"
    elif (core.is_client()):
        # !!!
        print "Client mode"
    elif (core.is_server()):
        # Import the Glances server module
        from .core.glances_server import GlancesServer

        # Init the server
        server = GlancesServer(bind_address=core.bind_ip, 
                               bind_port=int(core.server_port), 
                               cached_time=core.cached_time)
        print(_("Glances server is running on") + " %s:%s" % (core.bind_ip, core.server_port))

        # Set the server login/password (if -P/--password tag)
        if (core.password != ""):
            server.add_user(core.username, core.password)

        # Init stats
        # !!! Uncomment
        # stats = GlancesStatsServer()
        # stats.update({})

        # Shutdown the server
        # !!! How to close the server with CTRL-C
        # !!! Call core.end() with parameters ?
        server.server_close()