Magic Mirror Server Only Mode



  • Can we run single instance of magic mirror to cater to multiple clients with different module configuration. this is more of request where we let the Magic mirror run as Web Server and respond based on user profile and custom configuration?



  • @preetpuri I believe the answer is no.
    It’s still a single instance, configured at the server.



  • @sdetweil yeah, that’s what I think. I am trying to understand the flow in code to see if there is a simple/easier way to do it. Node.js not my strong suite so any inputs will be appreciated.



  • @preetpuri js/app.js is the core app starter.

    It is used from js/electron.js or serveronly/index.js

    js/server.js is the express web server

    Server.js sets up to load index.html
    Electron.js loads index.html into the electron browser window.
    Otherwise, other browsers cause the file to be loaded



  • Thanks, this helps. I made some quick changes in server.js to see if I can download different config.js based on user id (which has modules defined in it) but whenever browser renders with config1.js it shows me error page with “Please create a Config File”. So looks like config.js in tied or hardcoded with main app context. Still trying to troubleshoot but looks like it might not be that simple 😞

    var userId = req.query.user;
    		if(userId === undefined){
    			configFile = "config/config.js";
    			console.log(+configFile)
    		} else {
    			configFile = "config/config" + userId	 + ".js";
    			console.log(configFile)
    		}
    
    


  • @preetpuri yeh, its sort of backwards from what you want…

    it loads the config (app.start.loadconfig())
    loads the modules from the config (app.start.loadmodules())
    then starts the server from that config (app.start. new Server(config)

    what you want is
    load the config
    start the server

    on request/logon
    load the modules for this user
    redirect to index.html to load module side

    but this is not connection focused, therer is no unique storage by user/connection…



  • @sdetweil said in Magic Mirror Server Only Mode:

    but this is not connection focused no unique storage by user/connection…

    Not sure If I understand the last part? Connection will be handled by Express and I can add user management module later.

    What I am thinking is that if I am able to load multiple modules for different user (trying it with multi config file). I can add logic to save module configuration for each user in DB (may be mongo) and whenever user logs in - fetch the module configuration from DB for that user and voila !!! (again easier said then done :))



  • @preetpuri said in Magic Mirror Server Only Mode:

    and I can add user management module later.

    thats what I meant