Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run run rake task only once on next deploy #2057

Open
rusikf opened this issue Apr 28, 2020 · 6 comments
Open

Run run rake task only once on next deploy #2057

rusikf opened this issue Apr 28, 2020 · 6 comments

Comments

@rusikf
Copy link

rusikf commented Apr 28, 2020

Hi, is it possible to run custom command( ex: rake task ) only once on next deploy only?
I don't wan't to wait deploy, I want to run rake task only once ( On production for compatibility ), without running it manually and without rails migrations

@leehambley
Copy link
Member

If this solves your problem, please feel free to close the issue:

@rusikf
Copy link
Author

rusikf commented Apr 28, 2020 via email

@leehambley
Copy link
Member

I'm sorry I'm confused, in the first post you asked:

I don't wan't to wait deploy, I want to run rake task only once ( On production for compatibility ), without running it manually and without rails migrations

Sounds like you don't want this coupled to a deploy.

The easy way is to make use of rake task dependencies - https://subscription.packtpub.com/book/hardware_and_creative/9781783280773/1/ch01lvl1sec13/task-dependencies-prerequisites

You can definitely hook in to an existing rake task, or extend the capistrano deploy task with an extra step (capistrano's tasks/steps DSL is literally just rake)

@rusikf
Copy link
Author

rusikf commented May 4, 2020

yes, I understand that I can run any rake task on deploy, but it is possible to restrict run it only ONCE ? Looks, only if I add additional logic to redis or save to capistrano shared files, and check it, but may be it is possible with capistrano ?

@leehambley
Copy link
Member

yes, I understand that I can run any rake task on deploy, but it is possible to restrict run it only ONCE ?

Delete the code after you ran it? Use a lockfile, or a locking key in Redis?

@weedySeaDragon
Copy link

I've written a task (and the supporting) to do this.
You definitely have to have some way to record that you have run the task (e.g. in some sort of persistence: redis, a text file, db, ... whatever).

The code is specific to our system (how we decided to record if a task has been run), but if you still need help or want info about this, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants