changeset 21:dbe2232af20f

changed syncALONE
author Mathias Gebbe <mgebbe@intevation.de>
date Fri, 13 Jun 2014 21:21:41 +0200
parents 9436298e6d78
children b90e6df48d2d
files src/app.coffee src/syncALONE.coffee
diffstat 2 files changed, 39 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/app.coffee	Fri Jun 13 18:29:55 2014 +0200
+++ b/src/app.coffee	Fri Jun 13 21:21:41 2014 +0200
@@ -36,7 +36,7 @@
         on address %s port %d', config.address, config.port
 
         # Start Deamon!
-        # or comment to the next hashtag after ')' and user
+        # or comment to the next hashtag after ')' and use
         # Sync.sync()
         # or start coffee syncALONE.coffee in a different window
         exec = require("child_process").exec
--- a/src/syncALONE.coffee	Fri Jun 13 18:29:55 2014 +0200
+++ b/src/syncALONE.coffee	Fri Jun 13 21:21:41 2014 +0200
@@ -24,49 +24,40 @@
 syncFromESN = () ->
   console.log 'syncFromESN'
 
-  async.waterfall [
-    (callback) ->
-      db.connect(config.params, callback)
-    (callback) ->
-      ####
-      # Facebook
-    
-      try
-        Usermap.scan ((user) ->
-          if user.id.indexOf('@facebook') isnt -1
-            console.log "start sync for facebook user"
-            Facebook.sync(user)
-        ), (err) ->
-      catch err
-        console.log 'Error!' + err
-    
-      # Twitter
-      try
-        Usermap.scan ((user) ->
-          if user.id.indexOf('@twitter') isnt -1
-            console.log "start sync for twitter user"
-            Twitter.sync(user)
-        ), (err) ->
-      catch err
-        console.log 'Error!' + err
-    
-    
-      # Google
-      try
-        Usermap.scan ((user) ->
-          if user.id.indexOf('@google') isnt -1
-            console.log "start sync for google user"
-            Google.sync(user)
-        ), (err) ->
-      catch err
-        console.log 'Error!' + err
-      ####
-  ], (err, result) ->
-      console.log 'done'
+  ####
+  # Facebook
+  try
+    Usermap.scan ((user) ->
+      if user.id.indexOf('@facebook') isnt -1
+        console.log "start sync for facebook user"
+        Facebook.sync(user)
+    ), (err) ->
+  catch err
+    console.log 'Error!' + err
+
+  # Twitter
+  try
+    Usermap.scan ((user) ->
+      if user.id.indexOf('@twitter') isnt -1
+        console.log "start sync for twitter user"
+        Twitter.sync(user)
+    ), (err) ->
+  catch err
+    console.log 'Error!' + err
+
+  # Google
+  try
+    Usermap.scan ((user) ->
+      if user.id.indexOf('@google') isnt -1
+        console.log "start sync for google user"
+        Google.sync(user)
+    ), (err) ->
+  catch err
+    console.log 'Error!' + err
+  ####
 
   return
 
-
 postParser = (post, user, network, callback) ->
   parsed = ""
   #console.log "\n" + post.id + "\n" + user.id + user.displayName
@@ -133,9 +124,13 @@
   interval = config.interval
   if not (interval?)
     interval =  15 * 60 * 1000 # 900 000 ms (15min)
-  setInterval syncFromESN, interval
-
-  syncFromESN()
+   
+  async.waterfall [
+    (callback) ->
+       db.connect(config.params, callback)
+  ], (err, result) ->
+    setInterval syncFromESN, interval
+    syncFromESN()
 
   return
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)