scheduling a process

24 views
Skip to first unread message

Francesco Lunelli

unread,
Oct 22, 2021, 3:31:39 PM10/22/21
to Luminus
I'm developing a test site and I need a scheduled process running once a day to drop the database.
I wrote something like this using chime (the function I'm posting is called every minute, but it's only for testing purpose):

(defn scheduler [db]
   (let [now (Instant/now)]
       (chime/chime-at (-> (chime/periodic-seq (Instant/now) (Duration/ofMinutes 1)) rest)
      (fn [time]
         (drop-database db))
             )
       )
   )

Now I'm trying to find a way to start it automatically at startup.
I tried to call the function from -main in core.clj but it doesn't work.
It works if I force to evaluate the function (for example selecting the function and pressing ctrl-enter inside Visual Studio Code) but after a while all te site crashes.
But what I can't figure is the way to start it automatically.
Some hints?
Thanks

Francesco Lunelli

unread,
Oct 23, 2021, 3:12:54 AM10/23/21
to Luminus
Solved using defstate.


--
You received this message because you are subscribed to a topic in the Google Groups "Luminus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/luminusweb/00D5XXsVRIo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to luminusweb+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/luminusweb/8a0cacd2-4e25-4253-b851-19e86a093f05n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages