Server Autorestart



  • I would know if is actually possible to restart all the server in a certain hour from pufferpanel, because i really need that... i see the magic things with remote request but i am not sure how it work and if this work...



  • You could do this with a cron job

    Open up your con jobs:

    crontab -e
    

    add the command: (I use a cron job generator like this one http://www.generateit.net/cron-job/ )

    * 3 * * * /var/scripts/restart/darkrp.sh
    

    Then create a script like this:

    #!/bin/bash
    curl -X "GET" "localhost:5656/server/power/restart" -H "X-Access-Server: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -H "X-Access-Token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    

    Something like that should work but I haven't tested it



  • btw, how to do this curl request, but on PHP language?



  • like this

    <?php
    
    // Get cURL resource
    $ch = curl_init();
    
    // Set url
    curl_setopt($ch, CURLOPT_URL, 'https://static.pufferpanel.com:5656/server/power/on');
    
    // Set method
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    
    // Set options
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    // Set headers
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "X-Access-Server: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "X-Access-Token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
     ]
    );
    
    
    // Send the request & save response to $resp
    $resp = curl_exec($ch);
    
    if(!$resp) {
      die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
    } else {
      echo "Response HTTP Status Code : " . curl_getinfo($ch, CURLINFO_HTTP_CODE);
      echo "\nResponse HTTP Body : " . $resp;
    }
    
    // Close request to clear up some resources
    curl_close($ch);
    

    From : http://scales.pufferpanel.com/docs/serverpowerstatus



  • Error: "SSL certificate problem: self signed certificate" - Code: 60
    :) letsencrypt... need



  • add

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    

Log in to reply
 

Looks like your connection to PufferPanel Community was lost, please wait while we try to reconnect.