Skip to main content

Fehler beim sync-Skript

Comments

6 comments

  • Zendesk API User
    Author: luettel - 1/15/2014 7:07

    Ein ähnliches Problem habe ich auch bei diesem Skript.

    Führe den Befehl " ssh  -oBatchMode=yes -oStrictHostKeyChecking=no -l root localhost cp -R /opt/firstspirit5/web/fs5staging/158882/161651/* /home/usu/firstspirit/" auf der Console auf dem Server aus, dann funktioniert es ohne Problme. Nur mit FS nicht. Da erhalte ich folgende Fehlermeldung:

    INFO  15.01.2014 08:07:05.294 (de.espirit.firstspirit.server.sessionmanagement.SessionManagerImpl): new session (ID=4542608183296597432, user=SYSTEM, userID=0, type=DUMMY) created

    INFO  15.01.2014 08:07:05.295 (de.espirit.firstspirit.server.scheduler.ScheduleManagerImpl): starting task 'rsync' - schedule entry 'USU -- UXB-Graph Full Deployment' (id=161651)

    INFO  15.01.2014 08:07:05.310 (de.espirit.firstspirit.impl.access.ScriptContextImpl): rsync-ssh-Deployment for project "Integrations-Demo 2": script started

    INFO  15.01.2014 08:07:05.315 (de.espirit.firstspirit.impl.access.ScriptContextImpl): rsync-ssh-Deployment for project "Integrations-Demo 2": WrapperManager.exec(ssh -oBatchMode=yes -oStrictHostKeyChecking=no -l root localhost cp -R /opt/firstspirit5/web/fs5staging/158882/161651/* /home/usu/firstspirit/)

    ERROR 15.01.2014 08:07:05.401 (de.espirit.firstspirit.impl.access.ScriptContextImpl): rsync-ssh-Deployment for project "Integrations-Demo 2": failed with exitcode 255 for WrapperManager.exec(ssh -oBatchMode=yes -oStrictHostKeyChecking=no -l root localhost cp -R /opt/firstspirit5/web/fs5staging/158882/161651/* /home/usu/firstspirit/)

    INFO  15.01.2014 08:07:05.401 (de.espirit.firstspirit.impl.access.ScriptContextImpl): rsync-ssh-Deployment for project "Integrations-Demo 2": script completed

    INFO  15.01.2014 08:07:05.401 (de.espirit.firstspirit.server.scheduler.ScheduleManagerImpl): finished task 'rsync' - schedule entry 'USU -- UXB-Graph Full Deployment' (id=161651)

    //! Beanshell

    // FIRSTspirit script for scheduled deployment via rsync and ssh.

    // $Revision: 47547 $

    //

    // The script should be added via the project settings "Schedule management"

    // as an "Extended FirstSpirit script" after a "Generation Action" in a task.

    // It copies all changed generated files via rsync/ssh from the generation action

    // to the given path on the web server host.

    //

    // On first start, an error message is shown like

    // "Warning: Permanently added 'myhost' (RSA) to the list of known hosts.".

    // That message can be ignored and further runs does not show it.

    //

    // The script accepts the following parameters which can be added or changed

    // via "Script Properties" in the FirstSpirit task action.

    // Do not modify them in this script!

    import de.espirit.firstspirit.agency.ProcessAgent;

    webuser     = "";

    webhost     = "";

    webpath     = "";

    webinf      = "";

    privkey     = "";

    ssh         = "ssh";

    rsync       = "rsync";

    rsyncopts   = "-vcrt";

    rsyncopts2  = null;

    rsyncopts3  = null;

    rsyncopts4  = null;

    // end of variable definition

    tasklist = context.getTasks();

    t = context.getTask();

    s = t.getScheduleEntry();

    p = s.getProject();

    log = "rsync-ssh-Deployment for project \"" + p.getName() + "\": ";

    context.logInfo(log + "script started");

    params = t.getParameters();

    if (params == null) {

              context.logError(log + " failed. Missing parameters. "

                        + "Required: webhost, webuser, webpath. "

                        + "Optional: webinf, privkey, ssh, rsync, rsyncopts, rsyncopts2, rsyncopts3, rsyncopts4.");

              return;

    }

    for(pa: params) {

              switch(pa.getKey()) {

              case "webuser":

                        webuser = pa.getValue();

                        break;

              case "webhost":

                        webhost = pa.getValue();

                        break;

              case "webpath":

                        webpath = pa.getValue();

                        break;

              case "webinf":

                        webinf = pa.getValue();

                        break;

              case "privkey":

                        privkey = pa.getValue();

                        break;

              case "ssh":

                        ssh = pa.getValue();

                        break;

              case "rsync":

                        rsync = pa.getValue();

                        break;

              case "rsyncopts":

                        rsyncopts = pa.getValue();

                        break;

              case "rsyncopts2":

                        rsyncopts2 = pa.getValue();

                        break;

              case "rsyncopts3":

                        rsyncopts3 = pa.getValue();

                        break;

              case "rsyncopts4":

                        rsyncopts4 = pa.getValue();

                        break;

              }

    }

    if (webuser.equals("")) {

              context.logError(log + "failed. Parameter \"webuser\" missing.");

              return;

    }

    if (webhost.equals("")) {

              context.logError(log + "failed. Parameter \"webhost\" missing.");

              return;

    }

    if (webpath.equals("")) {

              context.logError(log + "failed. Parameter \"webpath\" missing.");

              return;

    }

    if (privkey.equals("")) {

              keyopt = "";

    } else {

              keyopt = "-i " + privkey;

    }

    cmd = new Vector();

     

    cmd2 = new Vector();

    cmd2.addAll(Arrays.asList(new String[]{ssh, "-oBatchMode=yes", "-oStrictHostKeyChecking=no", "-l", "root", "localhost",

        "cp -R /opt/firstspirit5/web/fs5staging/158882/161651/* /home/usu/firstspirit/"}));

    cmd.add(cmd2);

    for (c : cmd) {

              cmdstr = "";

              for (String s : c) {

                        cmdstr += " " + s;

              }

              cmdstr = "WrapperManager.exec(" + cmdstr.substring(1) + ")";

              context.logInfo(log + cmdstr);

              Process p = null;

              try {

                        p = context.requireSpecialist(ProcessAgent.TYPE).getBuilder().command(c).redirectOutput(log).start();

            result = p.waitFor();

            if ( result == 0 ) {

                context.logInfo(log + "command completed");

            } else {

                context.logError(log + "failed with exitcode " + result + " for " + cmdstr);

            }

              } catch (InterruptedException e) {

                        context.logError(log + "interrupted, for " + cmdstr);

              } catch (Exception e) {

                        context.logError(log + "failed for " + cmdstr + " - " + e);

              } finally {

                  if (p != null) {

                      p.destroy();

                  }

              }

    }

    context.logInfo(log + "script completed");

    0
  • Zendesk API User
    Author: luettel - 1/15/2014 7:24

    Genauso wie dieser Teil. Auf der Console klappt es, aber nicht bei FS.

    cmd2 = new Vector();

    cmd2.add(rsync);

    if (tasklist.size() <= 1) {

              // script testing mode

              // as at least one previous task for generating the files is needed

              cmd2.add("-n");

              srcpath = System.getProperty("cmsroot") + "/server/lib";

    } else {

              // normal scheduled mode

              i = context.getTaskIndex();

              if ( i <= 0 ) {

                        context.logError(log

                                            + "failed. No previous generate task found "

                                            + "in tasklist!");

                        return;

              } else {

                        srcpath = context.getPath();

              }

    }

    if (srcpath == null || srcpath.length() == 0) {

              context.logError(log + "failed. empty srcPath variable!");

              return;

    }

    // Replace something like c:\path with /cygdrive/c/path as rsync from

    // Cygwin does need this.

    if (srcpath.indexOf(":") >= 0) {

              srcpath = "/cygdrive/" + srcpath.charAt(0) + srcpath.substring(2);

    }

    if (rsyncopts!=null && rsyncopts.length() > 0) {

              cmd2.add(rsyncopts);

    }

    if (rsyncopts2!=null && rsyncopts2.length() > 0) {

              cmd2.add(rsyncopts2);

    }

    if (rsyncopts3!=null && rsyncopts3.length() > 0) {

              cmd2.add(rsyncopts3);

    }

    if (rsyncopts4!=null && rsyncopts4.length() > 0) {

              cmd2.add(rsyncopts4);

    }

    cmd2.addAll(Arrays.asList(new String[]{webhost + ":" + webpath}));

    cmd.add(cmd2);

    Fehlermeldung:

    ERROR 15.01.2014 08:23:57.802 (de.espirit.firstspirit.impl.access.ScriptContextImpl): rsync-ssh-Deployment for project "Integrations-Demo 2": failed with exitcode 23 for WrapperManager.exec(rsync -vcrt localhost:/home/usu/firstspirit)

    0
  • Zendesk API User
    Author: feddersen - 1/15/2014 9:59

    Hallo Daniel,

    du willst ein normales Rsync-Deplyoment machen? Dann brauchst du am Skript nichts zu modifizieren, sondern einfach nur in den Eigenschaften des Skriptes die Parameter entsprechend setzen. Wahrscheinlich wird durch deine Modifikationen einfach kein gültiges Kommando erzeugt. Wenn du sowieso auf der gleichen Maschine bist, kannst du natürlich auch einfach ins Dateisystem deployen.

    Viele Grüße

    Christoph

    0
  • Zendesk API User
    Author: luettel - 1/15/2014 10:04

    Hallo Christoph,

    ich bin aktuell auf dem gleichem Server, aber später soll das mal auf einen anderen Server.

    Wenn ich das normale Skript von euch aus der Doku benutze, dann erhalte ich auch einen Fehler.

    webuser=root

    webhost=localhost

    webpath=/home/usu/firstspirit

    Muss ich in dem Standars-Skript aus der Doku noch was setzen?

    Gruß

    Daniel

    0
  • Zendesk API User
    Author: feddersen - 1/15/2014 10:07

    Nein, da musst du nichts anderes setzen. Aber der User, mit dem FirstSpirit läuft, muss eben das Recht haben sich auf der Maschine als root über ssh einzuloggen. Das ist auf den meisten Maschinen per Default nicht erlaubt.

    0
  • Zendesk API User
    Author: luettel - 1/15/2014 10:12

    OK. Ich habe das jetzt mal mit dem fs5 user probiert und schon klappt es. Das ist ein guter Hinweis, welchen ich noch nicht kannte.

    Danke.

    Gruß

    0

Please sign in to leave a comment.