• 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

    How to automatically start Mango in a systemd based Linux OS

    How-To
    4
    5
    3.9k
    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.
    • A
      aoliver
      last edited by phildunlap

      Some Linux distributions as CentOS or RedHat are migrating from systemV init type to the newest systemd.

      If this is your case, you will need to do as follow to make Mango runs with every system startup:

      Create a mango.service file:

      touch /etc/systemd/system/mango.service
      chmod 664 /etc/systemd/system/mango.service

      Edit the new file so it contains the following:

      [Unit]
      Description=Mango Daemon Service
      After=network.target
      After=network-online.target

      [Service]
      Type=forking
      ExecStart=/opt/mango/bin/ma.sh start
      ExecStop=/opt/mango/bin/ma.sh stop
      ExecReload=/opt/mango/bin/ma.sh restart
      PIDFile=/opt/mango/bin/ma.pid

      [Install]
      WantedBy=multi-user.target

      NOTE: You will need to point the mango directory path to whatever your MA_HOME is.

      Reload systemd configuration files:
      systemctl daemon-reload

      Add mango to systemd, so it runs on every system startup:
      systemctl enable mango.service

      That's it. Now you can manage the Mango service with the following shell commands:

      systemctl [start|stop|reload|status] mango

      Good luck!

      Editted by Phil: original PIDFile entry --> PIDFile=/opt/ambilogger/bin/ma.pid, edited from ambiguity in: https://forum.infiniteautomation.com/topic/3179/centos-7-systemd-startup-failing

      danD 1 Reply Last reply Reply Quote 1
      • Jared WiltshireJ
        Jared Wiltshire
        last edited by

        I'll add an Upstart script for Ubuntu, I have been using this with Ubuntu 14.04. This one lets you run mango as a non-root user. Restart doesn't work too well as ma-stop.sh doesn't stop Mango immediately.

        From Ubuntu 15.04 onwards systemd is used instead of Upstart so dont use this script.

        # mango - Mango Automation
        #
        # Mango Automation is a Java web app for monitoring and logging data sources
        
        description     "Mango Automation"
        
        start on (local-filesystems and net-device-up IFACE=eth0)
        stop on runlevel [!2345]
        
        #respawn
        #respawn limit 10 5
        
        umask 002
        setuid mango
        setgid mango
        
        env MA_HOME=/opt/mango
        export MA_HOME
        
        console log
        
        script
                . "$MA_HOME"/bin/ma-init.sh
                export JPDA EXECJAVA JAVAOPTS SYSOUT SYSERR
                exec "$MA_HOME"/bin/ma-start.sh
        end script
        
        pre-stop script
                "$MA_HOME"/bin/ma-stop.sh
        end script
        

        Developer at Radix IoT

        P 1 Reply Last reply Reply Quote 0
        • P
          Phillip Weeks @Jared Wiltshire
          last edited by

          @Jared-Wiltshire
          Hi Jared I am wondering if you would generate a systemd script for our Ubuntu 16.04 LTS and show it here as the one provided above complains of an error when I tried this script in our system?
          I Appreciate any help on this.

          1 Reply Last reply Reply Quote 0
          • danD
            dan @aoliver
            last edited by

            @aoliver This worked for me on a RPi3 thanks!

            1 Reply Last reply Reply Quote 0
            • danD
              dan
              last edited by

              @aoliver said in How to automatically start Mango in a systemd based Linux OS:

              PIDFile=/opt/ambilogger/bin/ma.pid

              although, this PIDFile=/opt/ambilogger/bin/ma.pid should be /opt/mango/bin ;-)

              1 Reply Last reply Reply Quote 0
              • First post
                Last post