-
Notifications
You must be signed in to change notification settings - Fork 257
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
Fire and forget processes #162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
reload, | ||
restart, | ||
rmwatcher, | ||
run, | ||
sendsignal, | ||
set, | ||
start, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from circus.commands.base import Command | ||
from circus.exc import ArgumentError | ||
|
||
|
||
class Run(Command): | ||
"""\ | ||
Run a watcher | ||
============================== | ||
|
||
This command runs the process in a watcher | ||
|
||
|
||
ZMQ Message | ||
----------- | ||
|
||
:: | ||
|
||
{ | ||
"command": "run", | ||
"properties": { | ||
"name": '<name>", | ||
} | ||
} | ||
|
||
The response return the status "ok". | ||
|
||
If the property name is present, the watcher will be run. | ||
|
||
Command line | ||
------------ | ||
|
||
:: | ||
|
||
$ circusctl run <name> | ||
|
||
Options | ||
+++++++ | ||
|
||
- <name>: name of the watcher | ||
|
||
""" | ||
name = "run" | ||
|
||
def message(self, *args, **opts): | ||
if len(args) != 1: | ||
raise ArgumentError("invalid number of arguments") | ||
|
||
return self.make_message(name=args[0]) | ||
|
||
def execute(self, arbiter, props): | ||
if 'name' in props: | ||
watcher = self._get_watcher(arbiter, props['name']) | ||
watcher.run() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that should probably mentioned somewhere, but having a look at other commands you'll find out that we have the Also, if you do that, there's no real need to check that there is "name" in props, and you can just do "get_watcher" + run on it. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's worth mentioning here that this is a "one shot" thing. this is me nitpicking, but mainly this would be something in the lines of "This command runs one watcher's process and does not try to control it in any way". Like you said, this is a fire-n-forget thing, that's worth mentioning here. :-)