~openerp/openobject-server/trunk-speedup-need_action-tde

« back to all changes in this revision

Viewing changes to bin/openerp-server.py

  • Committer: Harry (Open ERP)
  • Author(s): xrg
  • Date: 2009-11-20 14:31:04 UTC
  • mfrom: (1119.1.208)
  • mto: (1898.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1900.
  • Revision ID: hmo@tinyerp.com-20091120143104-tb6136unkdw7yfy9
[merge] merge from lp:~xrg/openobject-server/optimize-5.0 and removed some confilts

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import sys
37
37
import os
38
38
import signal
 
39
import pwd
39
40
#----------------------------------------------------------
40
41
# ubuntu 8.04 has obsoleted `pyxml` package and installs here.
41
42
# the path needs to be updated before any `import xml`
48
49
elif os.path.exists(_oldxml2):
49
50
    sys.path.insert(0,_oldxml2)    
50
51
 
51
 
 
52
52
import release
53
53
__author__ = release.author
54
54
__version__ = release.version
55
55
 
 
56
# We DON't log this using the standard logger, because we might mess
 
57
# with the logfile's permissions. Just do a quick exit here.
 
58
if pwd.getpwuid(os.getuid())[0] == 'root' :
 
59
        sys.stderr.write("Attempted to run OpenERP server as root. This is not good, aborting.\n")
 
60
        sys.exit(1)
 
61
 
56
62
#----------------------------------------------------------
57
63
# get logger
58
64
#----------------------------------------------------------
105
111
# Load and update databases if requested
106
112
#----------------------------------------------------------
107
113
 
 
114
import service.http_server
 
115
 
 
116
if not ( tools.config["stop_after_init"] or \
 
117
        tools.config["translate_in"] or \
 
118
        tools.config["translate_out"] ):
 
119
        service.http_server.init_servers()
 
120
        service.http_server.init_xmlrpc()
 
121
 
 
122
        import service.netrpc_server
 
123
        service.netrpc_server.init_servers()
 
124
 
108
125
if tools.config['db_name']:
109
126
    for db in tools.config['db_name'].split(','):
110
127
        pooler.get_db_and_pool(db, update_module=tools.config['init'] or tools.config['update'])
145
162
 
146
163
 
147
164
#----------------------------------------------------------
148
 
# Launch Server
 
165
# Launch Servers
149
166
#----------------------------------------------------------
150
167
 
151
 
if tools.config['xmlrpc']:
152
 
    port = int(tools.config['port'])
153
 
    interface = tools.config["interface"]
154
 
    secure = tools.config["secure"]
155
 
 
156
 
    httpd = netsvc.HttpDaemon(interface, port, secure)
157
 
 
158
 
    xml_gw = netsvc.xmlrpc.RpcGateway('web-services')
159
 
    httpd.attach("/xmlrpc", xml_gw)
160
 
    logger.notifyChannel("web-services", netsvc.LOG_INFO, 
161
 
                         "starting XML-RPC%s services, port %s" % 
162
 
                         ((tools.config['secure'] and ' Secure' or ''), port))
163
 
 
164
 
#
165
 
#if tools.config["soap"]:
166
 
#   soap_gw = netsvc.xmlrpc.RpcGateway('web-services')
167
 
#   httpd.attach("/soap", soap_gw )
168
 
#   logger.notifyChannel("web-services", netsvc.LOG_INFO, 'starting SOAP services, port '+str(port))
169
 
#
170
 
 
171
 
if tools.config['netrpc']:
172
 
    netport = int(tools.config['netport'])
173
 
    netinterface = tools.config["netinterface"]
174
 
    tinySocket = netsvc.TinySocketServerThread(netinterface, netport, False)
175
 
    logger.notifyChannel("web-services", netsvc.LOG_INFO, 
176
 
                         "starting NET-RPC service, port %d" % (netport,))
177
 
 
178
168
LST_SIGNALS = ['SIGINT', 'SIGTERM']
179
169
if os.name == 'posix':
180
170
    LST_SIGNALS.extend(['SIGUSR1','SIGQUIT'])
189
179
    :param signum: the signal number
190
180
    :param _: 
191
181
    """
192
 
    if tools.config['netrpc']:
193
 
        tinySocket.stop()
194
 
    if tools.config['xmlrpc']:
195
 
        httpd.stop()
196
182
    netsvc.Agent.quit()
 
183
    netsvc.Server.quitAll()
197
184
    if tools.config['pidfile']:
198
185
        os.unlink(tools.config['pidfile'])
199
186
    logger.notifyChannel('shutdown', netsvc.LOG_INFO, 
210
197
    fd.write(pidtext)
211
198
    fd.close()
212
199
 
 
200
 
 
201
netsvc.Server.startAll()
 
202
 
213
203
logger.notifyChannel("web-services", netsvc.LOG_INFO, 
214
204
                     'the server is running, waiting for connections...')
215
205
 
216
 
if tools.config['netrpc']:
217
 
    tinySocket.start()
218
 
if tools.config['xmlrpc']:
219
 
    httpd.start()
220
 
 
221
206
while True:
222
 
    time.sleep(1)
 
207
    time.sleep(60)
223
208
 
224
209
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
225
210