REPORT de la branche 1.1 (459->476)
[euphorik.git] / tools / tools.rb
index 11570dd..b437687 100644 (file)
@@ -49,15 +49,16 @@ class VerifJS
    
    def verifierRecur(dossier)
       Dir.foreach(dossier){|fichier|
-         if fichier != '.' and fichier != '..' and File.directory?(fichier) and fichier != 'dirs'
-            if not verifierRecur(dossier + '/' + fichier)
+         cheminComplet = "#{dossier}/#{fichier}"
+         if fichier[0,1] != '.' and File.directory?(cheminComplet) and fichier != 'libs'
+            if not verifierRecur(cheminComplet)
                return false
             end
          elsif fichier[-3, 3] == '.js'
-            puts "== Vérification de #{dossier}/#{fichier} =="
+            puts "== Vérification de #{cheminComplet} =="
             # TODO : mettre un if pour la version windows si dessous 
-            #system("java org.mozilla.javascript.tools.shell.Main jslint.js #{dossier}/#{fichier}")
-            system("rhino ./tools/jslint.js #{dossier}/#{fichier}")
+            #system("java org.mozilla.javascript.tools.shell.Main jslint.js #{cheminComplet}")
+            system("rhino ./tools/jslint.js #{cheminComplet}")
             # puts $?.exitstatus
             if $?.exitstatus > 0
                return false
@@ -116,7 +117,7 @@ class MiseEnProd
    # Effectue la mise en production.
    def miseEnProd
       copierFichiers()
-      maj()
+      maj('yaws')
    end
    
    # Effectue la mise en préproduction.
@@ -124,6 +125,7 @@ class MiseEnProd
       copierFichiers()
       copierVAR()
       lancerYaws()
+      maj('yaws_dev')
    end
    
    def copierFichiers
@@ -144,7 +146,7 @@ class MiseEnProd
       creer_rep("tools")
       system("rsync tools/yaws.conf #{@uri}:#{@rep}/tools")
       system("rsync tools/start_yaws.sh #{@uri}:#{@rep}/tools")
-      # TODO
+      system("ssh #{@uri} \"cd #{@rep}/tools; screen -d -m -S yaws_dev ./start_yaws.sh\"")
    end
    
    def exec(commande)
@@ -159,6 +161,7 @@ class MiseEnProd
    end
    
    def compiler_partie_serveuse
+      log "compilation des modules serveur"
       Dir.chdir('modules')
       system("make")
       if $?.exitstatus != 0
@@ -178,6 +181,7 @@ class MiseEnProd
    
    # css, images, html, etc..
    def copier_partie_statique
+      log "copie de la partie statique"      
       uri = "#{@uri}:#{@rep}"
       system("awk '$0 !~ /prod=\"delete\"/' index.yaws | ssh #{@uri} \" cat > #{@rep}/index.yaws\"")
       system("rsync favicon.ico #{uri}")
@@ -188,6 +192,7 @@ class MiseEnProd
    
    # minification et package des fichiers js dans euphorik.js
    def pack_js
+      log "minification, assemblage et copie du javascript" 
       rep_js = 'js'
       creer_rep(rep_js)
       # jquery.js et euphorik.js doivent se trouve en premier
@@ -217,6 +222,7 @@ class MiseEnProd
    end
    
    def copie_modules_serveurs      
+      log "copie des modules du serveur" 
       # copie des modules erlang
       creer_rep('modules')
       system("rsync -r --exclude 'euphorik_test.beam' modules/ebin #{@uri}:#{@rep}/modules")
@@ -224,14 +230,24 @@ class MiseEnProd
    end
    
    def set_droits_fichiers
+      log "attribution des droits sur les fichiers" 
       # attribution des droits
       exec("chmod -R g+rx .")
    end
    
-   def maj
+   # noeud :  le nom du noeud sur lequel le script de mise en prod est exécuté
+   # Execute le script 'mise_en_prod.erl' sur le serveur afin de :
+   # - Recharger les modules
+   # - Mettre à jour la base de données
+   def maj(noeud)
+      log "rechargement des modules serveur et mise à jour de la base de données" 
       # execution du script de mise à jour
       system("cat tools/mise_en_prod.erl | ssh #{@uri} \"cat > /tmp/mise_en_prod.erl\"")
-      system("ssh #{@uri} \"chmod u+x /tmp/mise_en_prod.erl; /tmp/mise_en_prod.erl; rm /tmp/mise_en_prod.erl\"")
+      system("ssh #{@uri} \"chmod u+x /tmp/mise_en_prod.erl; /tmp/mise_en_prod.erl #{noeud}; rm /tmp/mise_en_prod.erl\"")
+   end
+      
+   def log(message)
+      puts "----- #{message} -----"
    end
 end
 
@@ -264,18 +280,7 @@ class Commande
             @verifJS.verifier()
          when 'version'
             @version.maj()
-      end
-      
-=begin
-      Net::SSH.start('euphorik.ch', 'gburri') {|ssh|
-         output = ssh.exec!("hostname")
-         stdout = ""
-         ssh.exec!("ls -l /tmp"){|channel, stream, data|
-            stdout << data if stream == :stdout
-         }
-         puts stdout
-      }
-=end
+         end
    end
    
    def afficherUsage