• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Script to restart mango

    Mango General
    3
    3
    2.7k
    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.
    • D
      Dan M
      last edited by Dan M

      Is there a way to restart the mango server from a script (like a RuntimeManager.restartInstance command)? I've been playing around with Mango (2.8.6 version) on a raspberry pi 3 and after a while, memory goes down. Once the JVM shows around 160MB free memory left, it will occasionally crash requiring a hard reboot. Is there a cheap and easy fix for now to just do a server restart? Not the ideal or finish solution, but will work for the time being..

      1 Reply Last reply Reply Quote 0
      • ThomasEinastoT
        ThomasEinasto
        last edited by

        Hi Dan,

        I did it by looking the PID of java, as Mango is a java application in the linux env.

        I made a bash program like that:

        #!/bin/bash
        
        if pgrep "java" > /dev/null
        then
        exit 0
        else
        sh /opt/mango/bin/ma.sh start > /dev/null
        exit 1
        fi
        
        

        And put this into a crontab like every x minutes which will check if the java application has crashed or not. If it has then it restarts the mango instance. You can put a reboot command after else so that it will reboot instead of relaunching the application.

        Thomas

        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by

          Hi Dan,

          One of the easiest ways to ensure Mango restarts on crash is to touch /path/to/mango/RESTART which will cause the ma-start.sh or ma-start.bat script to start Mango again when the currently running Mango finishes. Scripts in Mango/bin/ext-enabled are called with the first argument 'restart'

          To your question, yes it is possible to schedule a restart from within a Mango script, but there aren't any wrapper hooks, so you have to do it the same way the modules page would,

          com.serotonin.m2m2.web.dwr.ModulesDwr.scheduleRestart(); //Schedule restart for ten seconds from now.
          

          or you can get whatever delay you want,

          var timeout = com.serotonin.m2m2.Common.getMillis(com.serotonin.m2m2.Common.TimePeriods.MINUTES, 17);
          var lifecycle = com.serotonin.provider.Providers.get(com.serotonin.m2m2.IMangoLifecycle.class);
          lifecycle.scheduleShutdown( timeout, true /* restart */, null);
          1 Reply Last reply Reply Quote 0
          • First post
            Last post