GithubHelp home page GithubHelp logo

support mutiple instances about remi HOT 12 CLOSED

rawpython avatar rawpython commented on June 2, 2024
support mutiple instances

from remi.

Comments (12)

dddomodossola avatar dddomodossola commented on June 2, 2024

Yes, in case of different applications you can change the port by the configuration.py file. But maybe we can enable the library on finding automatically the best port number.

from remi.

nzjrs avatar nzjrs commented on June 2, 2024

yes I know I can change it, but what if I want to launch the same app with the same source code twice?

you can do something like this to get a random free port

server = TCPServer(('127.0.0.1', 0), Handler)
host, port = server.socket.getsockname()[:2]
print "we are on port", port

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

Fine, I will do this soon. ;-)

from remi.

KenT2 avatar KenT2 commented on June 2, 2024

If you are going to do this please make it optional. I intend to autostart the server when the Pi is powered up and a terminal window will not be open to see the port number that is printed.

The solution could be that if the port is left blank in configuration.py then a port is automatically selected. Presumably something will need to be done for the websocket port as well.

from remi.

nzjrs avatar nzjrs commented on June 2, 2024

The websocket port is an implementation detail. it should always be an ephemeral port

IMO, the default behaviour should be to just work - i.e. both ports should be ephemeral and random. Hardcoded ports should be optional unless you are targeting the framework to be used by only one app at a time...

from remi.

cyberpro4 avatar cyberpro4 commented on June 2, 2024

A great solution could be listen on default port (from code / configuration file) and, when already used, switch to random port

from remi.

nzjrs avatar nzjrs commented on June 2, 2024

I'm working on this, and cleaning up the whole configuration system, in https://github.com/nzjrs/gui/tree/multiple-instance

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

Ok John, but take care about the parameter MULTIPLE_INSTANCE in configuration.py file. This parameter changes the behavior of the server in case of multiple clients to the same App. If True, multiple instances of App class are created. If False instead, all the clients shares the same App class instance.

from remi.

nzjrs avatar nzjrs commented on June 2, 2024

Thanks, it was a bit confusing!

What would be a reason to run MULTIPLE_INSTANCE=True? I can't think of a use at the moment

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

Image a collaborative App, multiple user can interact on the same interface.. I do not have a specific use case now.

from remi.

cyberpro4 avatar cyberpro4 commented on June 2, 2024

A simple address book application, with a name/surname filter: when someone change the filter, this one shouldn't be shared with other clients.

from remi.

nzjrs avatar nzjrs commented on June 2, 2024

A simple address book application, with a name/surname filter: when someone change the filter, this
one shouldn't be shared with other clients.

how is the author of such an app expected to know which client they are talking to, and should they care? is it expected that you poke around in self.client_address from main? are all apps otherwise destined to be stateless?

I get the intention, but I wonder if the current implementation has been well considered.

from remi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.