MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Multiple "Mirrors" from a single device

    Scheduled Pinned Locked Moved Solved General Discussion
    20 Posts 3 Posters 3.2k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      sdetweil @DarrenO 0
      last edited by sdetweil

      @DarrenO-0 the json file my installer script creates is just to give the app name in pm2 a meaningful mame,

      if you use
      pm2 start mmfoo.sh
      the the app name will be mmfoo

      the watch function is broken, pm2 now only supports watching a folder for changes, but file updates don’t count as a folder change

      can you change the name of the script, yes, anything you like

      once you update the json file , just
      pm2 start xxxx.json
      and it will take the info from there

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      BKeyportB D 2 Replies Last reply Reply Quote 0
      • BKeyportB Offline
        BKeyport Module Developer @sdetweil
        last edited by BKeyport

        As I rewrote that section in the docs - I’ll give a (semi) live example (My second mirror is down due to lack of space, I’m working on a solution) - this is what works for me at the moment. I do realize I’m doubling up on some things.

        In my Pi’s config, I also reverted to X11 desktop rather than wayland for reasons unrelated. I have not tested this on Wayland.


        mm.sh

        cd /home/bkey1970/MagicMirror
        DISPLAY=:0 npm start
        

        mm2.sh

        cd /home/bkey1970/MagicMirror
        export MM_CONFIG_FILE=config/config2.js
        export MM_PORT=8081
        DISPLAY=:0 npm start
        

        the start of config.js:

        var config = {
        	address: "0.0.0.0",
        	port: 8080,
        	ipWhitelist: [],
        	language: "en",
        	timeFormat: 12,
        	units: "imperial",
        	//logLevel: ["INFO", "LOG", "WARN", "ERROR", "DEBUG"],
        	modules: [
        

        The start of config2.js:

        var config = {
        	address: "0.0.0.0",
        	port: 8081, 
        	electronOptions: { 
        		x: 1920
        	},
        	ipWhitelist: [], 
        	language: "en",
        	timeFormat: 12,
        	units: "imperial",
        	//logLevel: ["INFO", "LOG", "WARN", "ERROR", "DEBUG"],
        	customCss: "css/custom2.css",
        	modules: [
        

        PM2 commands to tie it all together:

        pm2 start /home/<username>/<path>/mm.sh --name "MM Main"
        pm2 start /home/<username>/<path>/mm2.sh --name "MM 2nd"
        pm2 save
        

        The "E" in "Javascript" stands for "Easy"

        D 1 Reply Last reply Reply Quote 0
        • D Offline
          DarrenO 0 @sdetweil
          last edited by

          @sdetweil
          OK, so no requirement to update the “name” and “watch” values in the .json file, but it doesn’t hurt to do so from an fyi perspective, right???

          When I run “pm2 start config2.js”, I can then access the second instance via browser on another device with no issue, but it also takes over the display directly connected to the MM host device.
          I can view both MM instances via a browser on different devices (great, as that was one of my original questions), but what if i want to view instance #1 via the display directly connected to the MM host device and instance #2 via a remote browser (or vice versa?

          My .sh files to start each MM instance are as follows:

          mm.sh
          #!/bin/bash
          cd ~/MagicMirror
          DISPLAY=:0 npm start

          mm2.sh
          #!/bin/bash
          cd ~/MagicMirror
          export MM_CONFIG_FILE=config/config2.js
          export MM_PORT=8081
          npm start
          #DISPLAY=:0 npm start

          Should I change anything, or what would I need to change, to have the desired outcome described above?

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @DarrenO 0
            last edited by

            @DarrenO-0 npm start run the ui locally and the server for remotes

            npm run server starts the server for remote and browsers locally

            both cases remotes need the server config to allow outside connection

            pm2 start xxxx
            where xxxx is the script name ( end in . sh)
            OR
            the json file where it can get the info

            the different config is set thru an environment variable
            MM_CONFIG_FILE=

            in linux by default env variables are NOT passed to children processes
            so you have to use export to
            make it passed on

            on Windows env variables ARE passed to children processes by default

            the port number is used on the remote system to access the appropriate instance

            http://mm-server-address:mm-instance-port-number

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            D 1 Reply Last reply Reply Quote 0
            • D Offline
              DarrenO 0 @sdetweil
              last edited by

              @sdetweil
              so mm2.sh should/would be:
              #!/bin/bash
              cd ~/MagicMirror
              export MM_CONFIG_FILE=config/config2.js
              export MM_PORT=8081
              npm run server
              #DISPLAY=:0 npm start

              while mm.sh remains untouched

              When I have this in place:

              • instance #1 correctly displays on the screen attached to the MM host… tick
              • i can also view instance #1 on a browser (on port 8080)… tick
              • can view instance #2 in a browser (on port 8081)… tick

              However, when I run mm2.sh while I am SSH’d to the MM, I am not returned to the command line so I can save the pm2 setup.
              I just have a prompt saying “Ready to go! Please point your browser to http://ipaddress:8081”

              I have to Ctrl-C to cancel out, which then stops the server function and the #2 instance is no longer displayed

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @DarrenO 0
                last edited by

                @DarrenO-0 in Windows when you want an app to run when started from the command prompt you do

                detach command…
                in linux you add and & as the last character

                comand… &

                now… STOPPING those detached/background things are tough…
                here is one value for pm2… it EXPECTS the script to block

                and so you can kill it thru pm2 stop xxxx
                BUT
                pm2’s JOB is to start and app AND KEEP IT RUNNING…
                so you kill it (ctrl-q) or it fails, pm2 will restart it

                SO, if you want both to run and want to do it manually, open a second ssh session
                until you are happy and then let pm2 run them both

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                D 1 Reply Last reply Reply Quote 0
                • D Offline
                  DarrenO 0 @sdetweil
                  last edited by

                  @sdetweil
                  OK, so I launched the second instance of MM via mm2.sh with the “npm run server” command.
                  I then launched a second SSH session to the MM device and issued a “pm2 save” command.
                  Rebooted the MM device from the second SSH session but the second MM instance didn’t come up.

                  S 1 Reply Last reply Reply Quote 0
                  • D Offline
                    DarrenO 0 @BKeyport
                    last edited by

                    @BKeyport
                    isn’t this to run two MM’s on a single display and have the second MM displayed from the 1920th pixel on the x axis?

                    I’m wanting to run two MM’s, each instance on isolated displays - one on the display connected to the host in the traditional method and the other on a remote display like another computer, or TV with an in-built browser.

                    S BKeyportB 3 Replies Last reply Reply Quote 0
                    • S Offline
                      sdetweil @DarrenO 0
                      last edited by sdetweil

                      @DarrenO-0 and what does the status say?

                      pm2 status
                      pm2 logs 1 (or whatever the number is of the line for the second ) --lines=xxxx
                      where xxxx is the number of the most recent lines in the log for that app

                      I have lots of apps on my desktop pm2
                      pm2 status output

                      | id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
                      ├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
                      │ 1  │ MagicMirror        │ fork     │ 27   │ stopped   │ 0%       │ 0b       │
                      │ 7  │ MagicMirror1       │ fork     │ 279… │ stopped   │ 0%       │ 0b       │
                      │ 0  │ Smart Mirror       │ fork     │ 31   │ stopped   │ 0%       │ 0b       │
                      │ 3  │ checkarec          │ fork     │ 0    │ online    │ 0%       │ 3.5mb    │
                      │ 6  │ smart-mirror       │ fork     │ 9    │ online    │ 0%       │ 3.5mb    │
                      │ 5  │ smart-mirror ttt   │ fork     │ 10   │ stopped   │ 0%       │ 0b       │
                      │ 4  │ start_alexa_bk     │ fork     │ 0    │ online    │ 0%       │ 3.5mb    │
                      │ 2  │ startspot          │ fork     │ 328  │ stopped   │ 0%       │ 0b       │
                      └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴────────
                      

                      the count under the circle coloum is restarts of that app

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      D 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @DarrenO 0
                        last edited by sdetweil

                        @DarrenO-0 the server side still provides access regardless of where the local display output is configured

                        AND if you run server mode, then the config for the local electron isn’t used

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          sdetweil @DarrenO 0
                          last edited by

                          @DarrenO-0 said in Multiple "Mirrors" from a single device:

                          or TV with an in-built browser.

                          just heads up…

                          we use the latest Javascript language options
                          most/many/all TV’s do NOT have this browser version available and cannot be upgraded.
                          so the MM screen will be black (browser crashed)

                          when I got here in 2017, I could run MM on my Samsung TV browser
                          not anymore

                          Sam

                          How to add modules

                          learning how to use browser developers window for css changes

                          D 1 Reply Last reply Reply Quote 0
                          • D Offline
                            DarrenO 0 @sdetweil
                            last edited by

                            @sdetweil
                            after running the mm2.sh script (runs as “npm run server”) and then I initiate a new SSH to the MM, I still only see a single instance (the original instance from mm.sh) of MM running when I issue a pm2 status command.
                            Although I can physically see the second MM displayed as desired in my browser, I’m not seeing the second instance via the pm2 status command.

                            S 1 Reply Last reply Reply Quote 0
                            • D Offline
                              DarrenO 0 @sdetweil
                              last edited by

                              @sdetweil
                              Fair enough.
                              So i’ll have to have a physical computer like a Pi, NUC or MiniPC attached to the TV via HDMI to display the MM via that computer’s browser.
                              Not a big deal as the TV would be used for viewing TV channels and online streaming content anyway.

                              1 Reply Last reply Reply Quote 0
                              • S Offline
                                sdetweil @DarrenO 0
                                last edited by sdetweil

                                @DarrenO-0 how did you add it to pm2 . just doing mm2.sh doesn’t

                                pm2 start xxxx
                                xxx is the mm2.sh
                                or the MagicMirror2.json
                                it should run and you should see with status

                                then pm2 save so that it will be saved to the bootup start list

                                Sam

                                How to add modules

                                learning how to use browser developers window for css changes

                                D 1 Reply Last reply Reply Quote 0
                                • D Offline
                                  DarrenO 0 @sdetweil
                                  last edited by

                                  @sdetweil
                                  yeah, I started it via the mm2.sh script that had the “npm run server” command
                                  I’ve now started the second instance as “pm2 start pm2_MagicMirror2_new.json” and “pm2 status” does show both instances running.
                                  Ran “pm2 save”, rebooted the host and both instances are showing as expected - MM#1 on the display connected to the host device, with MM#1 and MM#2 via a browser on a remote device/devices.

                                  S 1 Reply Last reply Reply Quote 0
                                  • S Offline
                                    sdetweil @DarrenO 0
                                    last edited by

                                    @DarrenO-0 awesome!!..

                                    now select which post is the one that you think ‘solved’ this
                                    hit the 3 dots (bottom right of the post) and click on Mark this post as the correct answer

                                    Sam

                                    How to add modules

                                    learning how to use browser developers window for css changes

                                    1 Reply Last reply Reply Quote 0
                                    • D DarrenO 0 has marked this topic as solved on
                                    • BKeyportB Offline
                                      BKeyport Module Developer @DarrenO 0
                                      last edited by

                                      @DarrenO-0 Ahh, gotcha. Yes, this is for two on the same system, which linux treats as one huge monitor.

                                      The "E" in "Javascript" stands for "Easy"

                                      1 Reply Last reply Reply Quote 0

                                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                      With your input, this post could be even better 💗

                                      Register Login
                                      • 1 / 1
                                      • First post
                                        Last post
                                      Enjoying MagicMirror? Please consider a donation!
                                      MagicMirror created by Michael Teeuw.
                                      Forum managed by Sam, technical setup by Karsten.
                                      This forum is using NodeBB as its core | Contributors
                                      Contact | Privacy Policy