Console-less OpenSim

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (removed redundant header)
(Added "screen" description)
Line 1: Line 1:
 +
 
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 &mdash; 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 <code>/etc/init.d/opensim</code>) and control it via the <code>RemoteAdminPlugin</code>, for example.
 
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 &mdash; 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 <code>/etc/init.d/opensim</code>) and control it via the <code>RemoteAdminPlugin</code>, 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 <code>screen -ls</code>. To attach a screen, use <code>screen -r Name</code>. From the example above that would be <code>screen -r OpenSim</code>. 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
 +
 +
{{obsolete}}
  
 
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 <code>-background True</code> commandline parameter:
 
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 <code>-background True</code> commandline parameter:

Revision as of 01:59, 27 September 2008

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 shutdown.py script (also located in share/python/console):

#!/usr/bin/python
# -*- 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')
        sys.exit(1)

    config = ConfigParser.ConfigParser()
    config.readfp(open(configFile))

    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
    else:
        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:

[opensim]
server = http://127.0.0.1:9000/
password = secret

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

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

(adapted from xyzzy xyzzy)'

Personal tools
General
About This Wiki