Welcome to the Dash Forum!

Please sign up to discuss the most innovative cryptocurrency!

How to check "auto restart" script

Discussion in 'Masternode Questions and Help.' started by semajjames, Dec 15, 2016.

  1. semajjames

    semajjames Member

    Joined:
    Feb 5, 2015
    Messages:
    154
    Likes Received:
    13
    Trophy Points:
    78
    I want to check my auto restart script is working ,,,

    does it make any difference if i manually stop using putty or my windows wallet ?

    cheers
     
  2. splawik21

    splawik21 Grizzled Member
    Dash Core Team Foundation Member Dash Support Group Moderator

    Joined:
    Apr 8, 2014
    Messages:
    1,916
    Likes Received:
    1,273
    Trophy Points:
    1,283
    you need to stop the deamon from your remote server and wait a bit checking if the proces started.
    I don`t know what the cycle you`ve setuped but if lets say after 10-15 min it does not start better start it manually so you`ll not get out of queue ;)
     
  3. studioz

    studioz Well-known Member

    Joined:
    Sep 10, 2014
    Messages:
    540
    Likes Received:
    464
    Trophy Points:
    163
    this is how i installed the reboot script , i haven't missed one payment since :
    https://status.bolehvpn.net/2016/02/07/what-is-a-dash-masternode-and-how-do-i-set-up-one/
    i'm a linux noob and was very easy for me , thx to Reuben from BolehVPN

    Step 8 Optional: Auto restart of dashd in the event of crash
    You can also install a monitor to auto restart dash if it crashes. This is optional. The below is taken from Moomoocow’s post:

    Install Monit

    sudo apt-get install monit

    Create file /home/user/.dash/start_dashd.sh (change user to yours)

    #!/bin/bash
    /bin/su user -c '/home/user/.dash/dashd 2>&1 >> /home/user/.dash/rc.local.log'

    Make it executable

    chmod 755 /home/user/.dash/start_dashd.sh

    Edit the file /etc/monit/monitrc

    sudo nano /etc/monit/monitrc

    Edit the file as follows:

    # uncomment these lines
    set httpd port 2812 and
    use address localhost # only accept connection from localhost
    allow localhost # allow localhost to connect to the server and
    # add this to bottom - change user to yours
    check process dashd with pidfile /home/user/.dash/dashd.pid
    start program = "/home/user/.dash/start_dashd.sh" with timeout 60 seconds
    stop program = "/bin/su user -c /home/user/.dash/dash-cli stop"

    Load the new configuration

    sudo monit reload

    Enable the watchdog

    sudo monit start dashd

    That’s it. You only have to do above once.
    You can check monit’s status by typing below:

    sudo monit status

    It’ll keep your dashd running for you (across reboots too, no need for any crons or scripts) and keep you from fighting with your chosen OS. Monit only runs once a minute, so be patient if you’re waiting for it to do something.

    If you need proof it works, once you see your dashd in the ‘sudo monit status‘ output, you can test it by simply stopping your dashd (dash-cli stop) — within 2 minutes it’ll start it back up,
     
    #3 studioz, Dec 15, 2016
    Last edited: Dec 15, 2016
  4. paraman

    paraman Active Member
    Foundation Member

    Joined:
    Mar 9, 2014
    Messages:
    23
    Likes Received:
    4
    Trophy Points:
    103
    Is Monit autostart above still working with 12.1 after changing paths from .dash to .dashcore?
     
  5. Chris Muller

    Chris Muller New Member

    Joined:
    Jul 12, 2016
    Messages:
    12
    Likes Received:
    3
    Trophy Points:
    3
    I was not able to tweak that to get monit to work with 12.1. After getting my masternode up and running on 12.1, I then decided I was ready to re-enable the monit monitoring. I updated the last three lines of /etc/monit/monitrc for the new .dashcore location:

    check process dashd with pidfile /home/myusername/.dashcore/dashd.pid
    start program = "/home/myusername/.dashcore/start_dashd.sh"
    stop program = "/home/myusername/.dashcore/dash-cli stop"

    Then, since I wasn't confident that dashman is ready to work well with 12.1, I changed start_dashd.sh to simply start dashd daemon instead of dashman. Like this:

    #!/bin/bash
    /bin/su myusername -c '/home/myusername/.dashcore/dashd -daemon'

    I then issued the command to start monitoring:

    sudo monit start dashd

    At which point monit immediately restarted dashd -- I presume to have the process under its control..

    Very shortly after, my masternode reported down and wouldn't come back up despite some fiddling. I wish I could remember what masternode debug told me... (arggh, I know I'm not being helpful).

    Taking monit out of the loop, and I'm back up with my unmonitored masternode.

    I love the peace of mind of a monit'd Masternode, any ideas?

    Best,
    Chris Muller
     
  6. GrandMasterDash

    GrandMasterDash Well-known Member
    Masternode Owner/Operator

    Joined:
    Jul 12, 2015
    Messages:
    2,703
    Likes Received:
    962
    Trophy Points:
    183
    Or, create a file /home/user/testdashd

    #!/bin/bash
    if ! [ `pidof dashd` ] ;then
    mail -s "MN1: dashd died" [email protected] < /dev/null
    /home/user/dashd > /dev/null
    fi​

    make it executable

    chmod 755 /home/user/testdashd​

    then create a cron job; crontab -e

    */5 * * * * /home/user/testdashd > /dev/null​
     
    • Like Like x 1
  7. qwizzie

    qwizzie Well-known Member

    Joined:
    Aug 6, 2014
    Messages:
    1,540
    Likes Received:
    725
    Trophy Points:
    183



    For v0.12.1 try to change it like this :

    Move dashd & dash-cli into .dashcore folder and make them executable

    For this script to work according below specs both dashd & dash-cli have to be installed and made executable inside .dashcore folder !!

    Install Monit

    sudo apt-get install monit

    Create file /home/user/.dashcore/start_dashd.sh (change user to yours)

    #!/bin/bash
    /bin/su user -c '/home/user/.dashcore/dashd 2>&1 >> /home/user/.dashcore/rc.local.log'

    Make it executable

    chmod 755 /home/user/.dashcore/start_dashd.sh

    Edit the file /etc/monit/monitrc

    sudo nano /etc/monit/monitrc

    Edit the file as follows:

    set httpd port 2812 and
    use address localhost # only accept connection from localhost
    allow localhost # allow localhost to connect to the server and
    check process dashd with pidfile /home/user/.dashcore/dashd.pid
    start program = "/home/user/.dashcore/start_dashd.sh" with timeout 60 seconds
    stop program = "/bin/su user -c /home/user/.dashcore/dash-cli stop"

    Use ALT & X to save


    sudo monit reload

    Make sure dashd is already running before doing next commands !

    sudo monit start dashd
    sudo monit status


    That’s it. You only have to do above once.

    It’ll keep your dashd running for you (across reboots too, no need for any crons or scripts) and keep you from fighting with your chosen OS. Monit only runs once a minute, so be patient if you’re waiting for it to do something.

    If you need proof it works, once you see your dashd in the ‘sudo monit status‘ output, you can test it by simply stopping your dashd (dash-cli stop) — within 2 minutes it’ll start it back up


    credits : studioz & Reuben from BolehVPN
     
    #7 qwizzie, Feb 16, 2017
    Last edited: Feb 16, 2017
    • Like Like x 1