Console-less OpenSim

From OpenSimulator

Revision as of 00:59, 27 September 2008 by Dutchie (Talk | contribs)

Jump to: navigation, search

normally opensim will only run in console mode: whenever you start OpenSim you will end up at a prompt inside OpenSim's very own console — which is very convenient if you want to manage it that way. it is rather inconvenient if you want to start OpenSim as a daemon in the background (e.g., from /etc/init.d/opensim) and control it via the RemoteAdminPlugin, for example.

As the suggested backgrounding below doesn't work for everyone, the option of using the package screen is a great alternative. Once screen is installed, use the following command to start the simulator:

   screen -S OpenSim -d -m mono OpenSim.exe

Once started, you can view the active session(s) listed with screen -ls. To attach a screen, use screen -r Name. From the example above that would be screen -r OpenSim. Once in the screen session, you can detach it by using Ctrl-A,D.

Killing a session without attaching it can be achieved by issuing:

   screen -S OpenSim -r -m  -X quit

as of OpenSim's subversion release r4400 the basic support for running OpenSim without such a console is in the code base and all you need to do is invoke OpenSim with the -background True commandline parameter:

   % mono --debug OpenSim.exe -background True

note: that is just a single dash for the -background option!

to shutdown a console-less OpenSim instance, use the following script (also located in share/python/console):

# -*- encoding: utf-8 -*-

import ConfigParser
import xmlrpclib
import optparse
import os.path

if __name__ == '__main__':
    parser = optparse.OptionParser()
    parser.add_option('-c', '--config', dest = 'config', help = 'config file', metavar = 'CONFIG')
    parser.add_option('-s', '--server', dest = 'server', help = 'URI for the grid server', metavar = 'SERVER')
    parser.add_option('-p', '--password', dest = 'password', help = 'password for the grid server', metavar = 'PASSWD')
    (options, args) = parser.parse_args()

    configFile = options.config
    if not configFile:
        if os.path.isfile(os.path.expanduser('~/.opensim-console.rc')):
            configFile = os.path.expanduser('~/.opensim-console.rc')
    if not configFile:
        parser.error('missing option config')

    config = ConfigParser.ConfigParser()

    server = config.get('opensim', 'server')
    password = config.get('opensim', 'password')
    if options.server: server = options.server
    if options.password: password = options.password

    gridServer = xmlrpclib.Server(server)
    res = gridServer.admin_shutdown({'password': password})

    if res['success'] == 'true':
        print 'shutdown of %s initiated' % server
        print 'shutdown of %s failed' % server

you can either pass in the server URI and password to use via commandline parameters, or you can create .opensim-console.rc in your home directory and set default values:

server =
password = secret

then all you need to do to shutdown your OpenSim server is invoke

the goal is to extend into a remote console of sorts.

(adapted from xyzzy xyzzy)'

Personal tools
About This Wiki