[Admin] PowerLaunch - A Better Server Launch Script [Windows]

Discussion in 'Bukkit Tools' started by TnT, Nov 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    TnT

    PowerLaunch
    A PowerShell based Minecraft server management tool.

    Features
    • Tests to ensure the server admin has the proper Windows dependencies.
    • Automatically relaunches the server when the server is stopped.
    • Creates a backup of everything in the server directory when the server stops.
    • Configuration File to control how this script works.

    How to Install
    • If using GitHub Download
      • See running unsigned Powershell scripts (below)
      • Unzip to a folder of your choice.
      • Run launch.ps1 to generate config files.
      • Stop the server. Upon relaunch of the server, the new values will be picked up.
    • If copying and pasting the launch.ps1 from GitHub
      • See running unsigned Powershell scripts (below)
      • Copy and paste the launch.ps1 from GitHub.
      • Save file as launch.ps1
      • Run launch.ps1 to generate config files.
      • Ensure config.txt has the values desired. Edit it and save.
      • Stop the server. Upon relaunch of the server or script, the new values will be picked up.
    Setup PowerShell to run unsigned scripts
    This is a one time only command to change PowerShell execution policy
    • Start Powershell as administrator
    • Run the following command
    Code:
    Set-ExecutionPolicy unrestricted
    Hit "Y" when prompted.
    • PowerShell, by default, expects signed scripts only. Setting this to unrestricted allows unsigned scripts to run.
    • While I would love to publicly sign this script, a 2 year certificate comes at a $550 cost (at least).
    Note: Once the above is done, you never need to do it again for that system.

    If you do NOT want to change your execution policy globally, you can run the script using this command:
    Code:
    powershell.exe -ExecutionPolicy Bypass -File Launch.ps1
    Configuration File (defaults)
    Configuration File (open)

    Code:
    SERVER_NAME=MyServer
    SERVER_LOCATION=
    BACKUP_LOCATION=
    CRAFTBUKKIT=craftbukkit.jar
    JAVA_FLAGS=-Xmx1G
    CRAFTBUKKIT_OPTIONS=-o True -p 25565
    TEST_DEPENDENCIES=True
    DELETE_LOG=False
    TAKE_BACKUP=True
    RESTART_PAUSE=5
    


    Configuration File (explanation)
    explanation (open)

    The name of the server. Used in Backups. Can be empty.
    Code:
    SERVER_NAME
    The folder for the server. This can be set to enable the launch.ps1 to be located anywhere on the system. Cannot be empty.
    Code:
    SERVER_LOCATION
    The folder where backups are placed. Can be empty if TAKE_BACKUP is set to false.
    Note: This folder should not be within the SERVER_LOCATION folder, as this script will backup everything in the SERVER_LOCATION. You don't need the backups backed up by this script.
    Code:
    BACKUP_LOCATION
    The server jar file. If you name your server cb.jar, modify this to reflect the same name. Cannot be empty.
    Code:
    CRAFTBUKKIT
    Set the min/max/initial heap size here. This can also be used to set other java flags (such as garbage collection).
    Code:
    JAVA_FLAGS
    Set the command line options to use to launch the server. Can be empty.
    Code:
    CRAFTBUKKIT_OPTIONS
    Checks to ensure .NET 4.5 and PowerShell 3 are installed. If not, it will provide download links.
    Code:
    TEST_DEPENDENCIES
    Allows the script to delete the server.log file if backup is enabled.
    Code:
    DELETE_LOG
    Enables the script to take a backup of the server upon shutting down the server.
    Code:
    TAKE_BACKUP
    How long to wait before automatically relaunching the server when stopped.
    Code:
    RESTART_PAUSE


    Long Term Goals
    • Better handling of CraftBukkit command line options.
    • Allow for a backup to run periodically, not just when the server stops.
    • Allow auto relaunch of server to be disabled.
    Note: Long term goals dependent on whether these features are desired or not.


    Source: https://github.com/TnTBass/PowerLaunch
     
  2. Offline

    TnT

    PowerLaunch v1.0.2 Released - Links in the main post have been updated

    • Added a keypress/pause to skip taking a backup
    • Added a backup notification - tell the user backups are about to happen
    • Added display to show size of server folder that will be backed up
    • Change server.log deletion from default of true to default of false and fix the log location for 1.7 log names
    • Added: Title bar name: PowerLaunch
    • Fixed a bug making the backup location no longer show \\ in some circumstances.
    A big thanks to DaddyEric and SyanaFox for helping to troubleshoot.
     
  3. Offline

    bobby3605

    I tried to run this script i did the allow unsigned scripts thing im getting this error can you tell me what im doing wrong?

    [​IMG]
     
  4. Offline

    TnT

    bobby3605
    Can you provide your config file for me to check please?
     
  5. Offline

    bobby3605

    Here is my config

    SERVER_NAME=NeedAName
    SERVER_LOCATION=F:\Server
    BACKUP_LOCATION=F:\Server\Backups
    CRAFTBUKKIT=craftbukkit.jar
    JAVA_FLAGS=-Xmx8G -Xms1G
    CRAFTBUKKIT_OPTIONS=-o True -p 25565
    TEST_DEPENDENCIES=True
    DELETE_LOG=True
    TAKE_BACKUP=True
    RESTART_PAUSE=5
     
  6. Offline

    TnT

    bobby3605
    What version of PowerLaunch are you running? Can you pastebin the Lauch.ps1 you have please?

    I noticed you are launching this script from a different location your server is located in - where is your config file located?
     
  7. Offline

    bobby3605

    sorry for late reply i am on power launch 1.0.2 pastebin for launch.ps1 here config file is in the same folder as launch.ps1
     
  8. Offline

    Jake6177

    Getting this:


    Code:
    Backup starting.  For large server directories, this may take a while.
    Size to be backed up: 0.02 GB. Hold please.
    Exception calling "CreateFromDirectory" with "4" argument(s): "The process cannot access the file
    'C:\Users\Jacob\Documents\Bukkit\s_backup\Jake6177 Dev Server-2014-01-13-19-21.zip' because it is being used by
    another process."
    At C:\Users\Jacob\Documents\Bukkit\launch.ps1:214 char:5
    +    [System.IO.Compression.ZipFile]::CreateFromDirectory($server, $backupFile, $ ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : IOException
     
     
    Backup Completed.  See C:\Users\Jacob\Documents\Bukkit\s_backup\Jake6177 Dev Server-2014-01-13-19-21.zip
    Config is:
    Code:
    SERVER_NAME=Jake6177 Dev Server
    SERVER_LOCATION=C:\Users\Jacob\Documents\Bukkit
    BACKUP_LOCATION=C:\Users\Jacob\Documents\Bukkit\s_backup
    CRAFTBUKKIT=cb.jar
    JAVA_FLAGS=-Xmx3G
    CRAFTBUKKIT_OPTIONS=-o True -p 25565
    TEST_DEPENDENCIES=True
    DELETE_LOG=False
    TAKE_BACKUP=True
    RESTART_PAUSE=5
    
    I'm running the version that's linked to in the OP.
     
  9. Offline

    TnT

    Jake6177
    Do you have the zip file open?

    I'm struggling to reproduce that problem. Can you open powershell, run this command and provide me the output please?
    Code:
    $PSVersionTable.PSVersion
     
  10. Offline

    Jake6177


    Nope.
     
  11. Offline

    TnT

    Please make sure you have no PowerShell.exe processes running and try again (perhaps give the PC a fresh reboot).
     
  12. Offline

    TheMysterious

    Solved my own problem by editing your script...
    Thanks for not responding -_-
     
  13. Offline

    TheMintyMate

    TnT
    Just wanted to ask: how do you stop the server (as it is set to constantly restart:p). Is there a command to stop it completely?
    P.S I wont be surprised if you don't reply, as I know you moving on in your life. Thank-you for your contribution to this community :)

    Edit: Ok, dork moment. I now see how to quit, thanks :p

    Got the same issue....

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  14. Offline

    TnT

    His problem lists that the backup file is currently in use. I asked him for the output of "$PSVersionTable.PSVersion" in a PowerShell window, but have not received it. Can you provide that output please?
    I am curious if perhaps the backup is not being closed properly or something.
     
  15. Offline

    Jake6177

    Sorry I haven't been able to reproduce the problem.
     
  16. Offline

    TheMintyMate

    Ok, Here is the output:
    Code:
    Major  Minor  Build  Revision
    -----  -----  -----  -----
    4      0      -1     -1
    
    Hope that helps :)
     
  17. Offline

    TnT

    I just realized... you probably have your backup folder inside your server folder.

    From my documentation on the config file:
    You're basically causing the script to backup your backups every time it wants to take a backup. Yo dawg...
     
  18. Offline

    TheMintyMate

    Oh yeah :p Thanks :)
     
Thread Status:
Not open for further replies.

Share This Page