Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-3661

restart-script in spigot.yml with arguments to execute

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None

      When using the "restart"-Command or when the server crashes, the runtime will execute the script from the spigot.yml. There you can specify the name of the script but no further arguments. I have a single script which can start all of my servers and there I need only an argument (For me a servername). With the given Code in the restart Command it is impossible to start a script with arguments. It doesn't work on windows and linux.

      I have two solutions:

      1. You split the String on spaces, but then you cant have a scriptname with spaces
        You would also need to check only the first argument if it is a command
      2. You add another (could be alternative) path in the spigot.yml like "settings.restart-arguments", which you then split on spaces and add them to the arguments

      In the restart-Command I found this source code and marked the problem:

      There you can see that the restart-script is given as a single String and not as single arguments.

                      Thread shutdownHook = new Thread()
                      {
                          @Override
                          public void run()
                          {
                              try
                              {
                                  String os = System.getProperty( "os.name" ) .toLowerCase(java.util.Locale.ENGLISH);
                                  if ( os.contains( "win" ) )
                                  {
                                      Runtime.getRuntime().exec( "cmd /c start " + script.getPath() );
                                  } else
                                  {
                                      Runtime.getRuntime().exec( new String[]
                                      {
                                          "sh", script.getPath() <= HERE IS THE PROBLEM
                                      } );
                                  }
                              } catch ( Exception e )
                              {
                                  e.printStackTrace();
                              }
                          }
                      };
      

            Unassigned Unassigned
            Jubeki Jubeki
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: