scala - Execute external script on server with multiple play 2 framework instances -
i have linux server 3 play 2 framework instances on , execute regularly external scala script has access application environment (models) , executed 1 time @ time.
i phone call script crontab cannot find documentation on how it. know can schedule asynchronous tasks global object, want script executed 1 time 3 play instances.
actually same kind of things ruby on rails rake tasks knows them.
create regular action
task accessible via http, can utilize ie. curl
in unix' crontab
phone call action , nail first available instance.
other possibility is... using global
object schedule task akka
support. in case create sure 1 instance schedule task, need determine somehow 1 should be. if starting 3 instances specified port (always same per instance) can read http.port
allow or skip execution.
finally can utilize database inform other instances, task executed: 3 instances tries execute akka scheduler, before execution task can check if task has still todo flag. if not, instance sets todo flag false , continues execution, otherwise skips execution time.
also can utilize filesystem similar approach: @ origin of execution, create flag-file inform other instances, that, time can skip task.
scala cron playframework-2.0
No comments:
Post a Comment