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

Adding run_once functionality #43

Closed
wants to merge 12 commits into from
Closed

Conversation

hdahme
Copy link
Contributor

@hdahme hdahme commented May 22, 2015

Adds the ability to lock a command to the calling process - with the optional limit that the command can only be run once an interval

Usage

To run the echo command once, across a cluster of servers, and to ensure that it's only run once every 60 seconds

consulate run_once -i 60 echo_hello 'echo hello'
>>> hello
consulate run_once -i 60 echo_hello 'echo hello'
>>> Last run happened fewer than 60 second ago. Exiting

This relies on using consulate's existing acquire_lock function as well as setting a lock with a unique name, such that subsequent executions can reference the last time the command was run

adapter = adapters.UnixSocketRequest
port = None
api_host = os.environ.get('CONSUL_HTTP_ADDR').replace('unix://', '')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here? it seems you're neutering the unix socket interface intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmr I'm trying to simplify the command line arguments when connecting with a unix socket. If we're using sockets, the idea is to read the socket location from Consul's stored environment variable, instead of requiring it over the command line.

I could use the environment variable as the default and override if it's passed in as an arg

@gmr
Copy link
Owner

gmr commented Jun 6, 2015

This looks good other than removing http+unix. Can you let me know what the thought is in that change?

@hdahme
Copy link
Contributor Author

hdahme commented Jun 22, 2015

@gmr I re-instituted http+unix, and updated this pull request to set the default of the api_host to be api_scheme-specific. Let me know what you think!

@gmr
Copy link
Owner

gmr commented Jul 4, 2015

Looks reasonable, any chance you can rebase off master?

@hdahme
Copy link
Contributor Author

hdahme commented Jul 14, 2015

@gmr closing this in favour of #57

@hdahme hdahme closed this Jul 14, 2015
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

Successfully merging this pull request may close these issues.

4 participants