• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

PM2 for server mode

Scheduled Pinned Locked Moved Unsolved Feature Requests
4 Posts 2 Posters 146 Views 2 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
    sifuhall
    last edited by 26 days ago

    What must I do to use pm2 to launch in server mode at boot?

    My eventual goal is to have multiple instances running server mode on multiple ports. As I understand it I need to copy the MagicMirror directory for each instance and change ports.

    But how can I launch them at boot with PM2?

    Thank you!

    S 1 Reply Last reply 26 days ago Reply Quote 0
    • S Offline
      sdetweil @sifuhall
      last edited by sdetweil 26 days ago 26 days ago

      @sifuhall

      change the command in the script pm2 starts

      as for multiple instances you can do it all from one folder

      use the MM_CONFIG_FILE environment variable
      and maybe MM_PORT variable

      see
      https://docs.magicmirror.builders/configuration/introduction.html#advanced-configuration-and-frequently-asked-how-to-configure-examples

      you can start them all in one script, but hard to stop
      they can all use the same config file and use MM_PORT to
      override what is in the config file
      or use a different config file too

      you can install all modules in the one folder
      and use different modules in different instances

      npm run server
      instead of
      npm run start

      then
      pm2 start server1.sh
      pm2 start server2.sh

      etc
      pm2 save

      pm2 status should show them running

      reboot

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      S 1 Reply Last reply 25 days ago Reply Quote 1
      • S Offline
        sifuhall @sdetweil
        last edited by 25 days ago

        @sdetweil Thank you!

        S 1 Reply Last reply 25 days ago Reply Quote 0
        • S Offline
          sdetweil @sifuhall
          last edited by sdetweil 25 days ago 25 days ago

          @sifuhall one thing
          pm2’s job is to keep the app running. so when the script ends it restarts

          in windows to spin off a separate task you use detach

          detach xxxx.bat

          in
          linux you use the & as last character

          xxx.sh &

          so if you choose to launch from one script

          # use port in config.js
          npm run server &
          # override port in config.js
          export MM_PORT=8090
          npm run server &
          # override port in config.js
          export MM_PORT=8100
          npm run server &

          there is nothing to keep the script running
          and pm2 will relaunch it

          just remove the last &
          and bash will wait for that command to end(never)
          pm2 will be happy

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            1/4
            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