How to recover Go timer from web-server restart (or code refresh/upgrade)? -


Consider a web service, for example, where a user can request an API to start a task at certain times Work definition and fixed time is persisted in a database My first approach is to start the go timer and wait for the timer to end in the Gorotine (do not block the request). After the expiration of time, this Gourantine will also set fire to another API request to execute the task.

Now this problem occurs when this service is deployed. For zero downtime deployment, I am using it with the reloaded code, obviously Göttingen dies in the timer goratinine and the timer expires. Is there a way to recover the go timer after reloading the code?

I am struggling with another problem, which allows the user to get the timer (once started) timer to facilitate this feature. But since it is a stateless API, when the \ interrupt request arrives in the service, the timer is not a reference to the channel. And it seems that it is not possible to martial disc / db from channel (back).

It is also very possible that I am not seeing this problem from the right perspective. Any suggestion would be highly appreciated.

One of the commonly used methods is to schedule work outside your app, for example Use a crontab or system timer.

Use the crontab for example:

  # 30 min * 30 min * * * * / usr / bin / curl - head http: // localhost / cron ? Key = something-to-verify-local-job & gt; / Dev / null 2 ​​& gt; & Amp; 1   

Using an external work queue is also a valid option, such as @not_a_golfer mentioned but more complex

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -