1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Restart server from plugin?

Discussion in 'Development' started by HittmanA, Nov 21, 2016.

  1. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    In a plugin I am developing I need to be able to restart the server from the plugin. How can I do this?
     
  2. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    Use $this->getServer()->shutdown
     
  3. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    Thanks!
     
  4. Reid

    Reid Spider Jockey

    Messages:
    43
    As far as I know you cannot do this within a plugin only you could edit the start.sh/cmd though I recommend taking a look at this https://github.com/iJoshuaHD/ASR
     
    HittmanA likes this.
  5. BalAnce

    BalAnce Silverfish

    Messages:
    22
    GitHub:
    YaBoiBalAnce
    Simple way is to edit start.sh
    and change following line to yes
    Code:
    DO_LOOP="yes"
     
  6. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    If you are using windows, there is a new start thing I've made. https://github.com/NotPocketMine/Auto-Restart/releases
    There are two restarter programs. One Color, and One Plain.
    The Color one is recommended.

    They both will use your file 'server.properties'.

    CATION:
    This is a brand new tool. This tool has not been accepted by the PMMP Forum staff, nor has been accepted on the old PocketMine forum. Use at your own will.
     
    HittmanA and Reid like this.
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    only thing would be to call PM shutdown
    and run something like system({somehow wait for PM to fully shutdown(without stopping pm from stopping)} $phpbin $pmmp.phar)
    the wait pm to exit and the command will run it back up
    that repo is suspicious with no code base
     
    Reid likes this.
  8. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    Suspicious... mmk... good point. If I look at it through someone else's views...
    The only reason I didn't add the code, is due to "People who don't know what they are doing at anything/noobs" breaking stuff.
    Should I add it?
     
  9. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    Or send a command via console, not a good practice but still
     
    HittmanA likes this.
  10. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    True
     
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    The start.sh is not for editing. You can start the server with the -l option:
    Code:
    ./start.sh -l
    This will start the server with loops.
     
    BalAnce, ifvictr, falk and 2 others like this.
  12. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Well they cant break anything you can just reject their PR
    and if they choose to break it, it is their own fault
     
    HBIDamian likes this.
  13. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Asking how to restart server from plugin is like asking how to choose your identity in your next life. Unless you can get in contact with and affect the behaviour of the god or whatever deities in charge of spirits, you can't change it. And it is always very dangerous for a human to try to do so.
     
  14. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    Last edited: Nov 22, 2016
    Thunder33345 likes this.
  15. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    Technically the religion of Buddhism is based on the purpose of escaping the reincarnation cycle. So in that sense my plugin must be a master at meditation to escape the server cycle.
     
    SOFe likes this.
  16. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    :O Better start meditating, plugin!
     
  17. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    I hear my plugin: OOOOOOOOOooooooooOOOOOOOOOmmmmmmmmmmmmmmmmmm
     
  18. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    This describes what happens when I meditate:
    PHP:
    function meditate(){
      if(
    thoughtOfSOmethingInteresting()) postRandomTweets();
      else 
    meditate();
    }
    function 
    postRandomTweets(){
      
    openBrowser();
      
    meditate();
      
    sendTweet(); // DEAD CODE
    }
    function 
    thoughtOfSomethingInteresting(){
      return 
    rand(110) > 9// 90% probability returns false
    }
    Similarly, how does a plugin meditate? It waits until the next server starts and ends. Terrible idea.

    In addition: In case of stack overflow, in humans, the brain chooses to delete the oldest stack instead.
     
    Last edited: Nov 23, 2016
  19. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Comedy!
     
    HBIDamian likes this.
  20. HBIDamian

    HBIDamian HBIDamian Staff Member

    Messages:
    365
    GitHub:
    HBIDamian
    correction:

    Ha, Comedy!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.