1

I've got some code that creates a node in the Firebase Realtime Database when a button is pressed on my app. I want to delete this node 24 hours from its creation time (something similar to the stories feature in Social media platforms nowadays). This deletion should take place even if the app isn't running, is this possible with Vapor? If not, is there any way I could achieve this? Appreciate the feedback!

  • It seems to be possible to run code on a schedule in Vapor: https://stackoverflow.com/questions/41898944/how-to-use-timer-in-vapor-server-side-swift/55539678#55539678 Did you try anything yet? – Frank van Puffelen Nov 05 '19 at 15:56
  • I haven't tried anything yet, cuz I don't know where to start – QPandTS Pvt. Ltd Nov 05 '19 at 16:04
  • I've never used Vapor before either, but the question I linked seems to have a pretty good starting point in `timer.schedule(...)`. – Frank van Puffelen Nov 05 '19 at 16:09
  • 1
    Looks like you should have every minute task which will check which stories are ready to be removed and remove them. Vapor have schedule libraries which can execute repeated tasks. – imike Nov 05 '19 at 16:13
  • @imike this can run even if the app isn't running right? – QPandTS Pvt. Ltd Nov 05 '19 at 16:19
  • Which app? Server-side vapor app or iOS? If iOS app then yes cause Vapor app should be running all the time cause it's server-side. If you want to have server-side app not running all the time you should use classic cron on the server to run vapor app time after time. – imike Nov 05 '19 at 17:40
  • @imike ohh okay, is it possible to run a python file that updates the database using cron? – QPandTS Pvt. Ltd Nov 05 '19 at 19:34
  • @QPandTSPvt.Ltd sure you can execute any script by classic crontab, just google: crontab execute script every minute – imike Nov 05 '19 at 19:39

0 Answers0