1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
26 #.apidoc title: RPC Services
28 """ Classes of this module implement the network protocols that the
29 OpenERP server uses to communicate with remote clients.
31 Some classes are mostly utilities, whose API need not be visible to
32 the average user/developer. Study them only if you are about to
33 implement an extension to the network protocols, or need to debug some
34 low-level behavior of the wire.
39 http_server = openerp.service.http_server
40 netrpc_server = openerp.service.netrpc_server
42 # Instantiate local services (this is a legacy design).
43 openerp.osv.osv.start_object_proxy()
44 # Export (for RPC) services.
45 openerp.service.web_services.start_web_services()
47 # Initialize the HTTP stack.
48 http_server.init_servers()
49 http_server.init_xmlrpc()
50 http_server.init_static_http()
51 netrpc_server.init_servers()
53 # Start the main cron thread.
54 openerp.netsvc.start_agent()
56 # Start the top-level servers threads (normally HTTP, HTTPS, and NETRPC).
57 openerp.netsvc.Server.startAll()
64 openerp.netsvc.Agent.quit()
65 openerp.netsvc.Server.quitAll()
66 config = openerp.tools.config
67 logger = logging.getLogger('server')
68 logger.info("Initiating shutdown")
69 logger.info("Hit CTRL-C again or send a second signal to force the shutdown.")
72 # manually join() all threads before calling sys.exit() to allow a second signal
73 # to trigger _force_quit() in case some non-daemon threads won't exit cleanly.
74 # threading.Thread.join() should not mask signals (at least in python 2.5)
75 for thread in threading.enumerate():
76 if thread != threading.currentThread() and not thread.isDaemon():
77 while thread.isAlive():
78 # need a busyloop here as thread.join() masks signals
79 # and would present the forced shutdown
84 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: