Example #1
0
def main():
    config = Config.instance()
    config.read("%s.ini" % path.splitext(__file__)[0])

    daemon = ProxyDaemon()
    if config.daemon and hasattr(os, "fork"):
        daemon.start()
    else:
        daemon.run()
Example #2
0
def main():
    config = Config.instance()
    config.read("%s.ini" % path.splitext(__file__)[0])

    daemon = ProxyDaemon()
    if config.daemon and hasattr(os, "fork"):
        daemon.start()
    else:
        daemon.run()
Example #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("mode",
                        help="select run mode, can be 'install' or 'daemon'."
                             "Install mode just flashes firmware to chip, "
                             "daemon mode runs cloud connector from the "
                             "firmware side, do not call it manually.")
    args = parser.parse_args()
    if args.mode == "install":
        print("Flashing MCU with avrdude...")
        subprocess.call(["run-avrdude",
                         os.path.join(os.path.dirname(
                                os.path.realpath(__file__)),
                            "lora-gateway-firmware.ino.arduino_standard.hex"),
                         "-v", "-patmega328p"])
    elif args.mode == "daemon":
        logging.StreamHandler(stream=None)
        daemon.run()
    else:
        print("Unknown mode. Use -h for help.")
Example #4
0
def daemon():
    """Run the daemon which refreshes desktop image when desktop changes"""
    click.echo("Yo dude, daemon is running")
    run()
Example #5
0
        "pidfile": '',
        "access_log": '',
        "error_log": '',
        "document_root": '',
        "template": AML_TEMPLATE,
        "template_vars": {
            "APPNAME": AML_APPNAME,
            "CONTENT_TYPE": 'text/html',
        },
    }

    conf.update(DataStore.CONFIG_DEFAULTS)
    argv.append('--config=/etc/abe.conf')
    args, argv = readconf.parse_argv(argv, conf)
    if argv:
        sys.stderr.write("Error: unknown option `%s'\n" % (argv[0], ))
        sys.exit(1)

    daemon = MyDaemon(args)
    if cmd == 'start':
        daemon.start()
    elif cmd == 'stop':
        daemon.stop()
    elif cmd == 'restart':
        daemon.restart()
    elif cmd == 'run':
        daemon.stop()
        daemon.run()

    sys.exit(0)
Example #6
0
        "pidfile":      '',
        "access_log":   '',
        "error_log":    '',
        "document_root":'',
        "template":     AML_TEMPLATE,
        "template_vars": {
            "APPNAME": AML_APPNAME,
            "CONTENT_TYPE": 'text/html',
            },
        }

    conf.update(DataStore.CONFIG_DEFAULTS)
    argv.append('--config=/etc/abe.conf')
    args, argv = readconf.parse_argv(argv, conf)
    if argv:
        sys.stderr.write("Error: unknown option `%s'\n" % (argv[0],))
        sys.exit(1)

    daemon = MyDaemon(args)
    if cmd == 'start' :
        daemon.start()
    elif cmd == 'stop' :
        daemon.stop()
    elif cmd == 'restart' :
        daemon.restart()
    elif cmd=='run':
        daemon.stop()
        daemon.run()

    sys.exit(0)
Example #7
0
def run_daemon(robot_name: str, url: str):
    set_host(url)
    daemon.run(robot_name, url)
Example #8
0
from daemon import run

run()
Example #9
0
        self.new_socks.append(sock)

    def __remove_new_sock(self, sock):
        sck_id = str(sock)
        del self.sock_reader[sck_id]
        del self.data_of_new_socks[sck_id]
        self.new_socks.remove(sock)

    def __load_domain_mapping(self):
        for usr in self.cfg['users']:
            for m in self.cfg['users'][usr]['http']:
                self.domain_to_host[m[0]] = (usr, m[1])


def main_shutdown():
    print "main shutdown"


def main():
    # 注册退出回调函数
    #atexit.register(main_shutdown)
    logger = common.init_logger("server")
    proxy = Proxy(logger)
    proxy.start()
    proxy.join()
    logger.info('server end')


if __name__ == "__main__":
    daemon.run('server', main)
Example #10
0
##
#    This file is part of Overkill.
#
#    Overkill is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Overkill 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Overkill.  If not, see <http://www.gnu.org/licenses/>.
##

from daemon import run
run()
Example #11
0
        if proxy_side_sck is None:
            # setup fail
            sck.send("built fail %s;" % waiting_id)
            self.logger.error("built fail %s;" % waiting_id)
            return

        sck.send("built ok %s;" % waiting_id)
        proxy_side_sck.send("tunnel %s %s;" % (self.my_name, waiting_id))
        self.logger.info("built ok %s;" % waiting_id)

        # set two scoket as forwarding pair
        forwarding = common.TcpForwarding(waiting_id)
        forwarding.sck_side_A = local_side_sck
        forwarding.sck_side_B = proxy_side_sck
        forwarding.start()

    def on_registered(self, sock, params):
        #print "tcp porting mapping %s"%" ".join(params)
        self.logger.info("tcp porting mapping %s" % " ".join(params))
        if params[0] == 'ok':
            self.registered = True


def main():
    c = ClientPoint()
    c.main()


if __name__ == "__main__":
    daemon.run('client', main)