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

Execute a task only on first node from a pull #1311

Closed
alinalexandru opened this issue Jul 25, 2017 · 4 comments
Closed

Execute a task only on first node from a pull #1311

alinalexandru opened this issue Jul 25, 2017 · 4 comments
Labels

Comments

@alinalexandru
Copy link
Contributor

alinalexandru commented Jul 25, 2017

Q A
Issue Type Feature Request
Deployer Version N/A
Local Machine OS N/A
Remote Machine OS N/A

Description

For example you have to execute a command only once. I don't like a idea of hardcode o server name when defining a task.

Instead of doing

task('only:once', function (){
....
})->onHosts('frist.node')

I propose to have a method onFirstHost for example, that will limit the task execution to the first node from available.

task('only:once', function (){
....
})->onFirstHost()

If you consider that is an good idea, I can propose a PR with the implementation.

@richsage
Copy link
Contributor

+1, I've used some variation of this before:

task('only:once', function () {
    static $runOnce = false;
    if ($runOnce) {
        return;
    }

    $runOnce = true;
    // ...
});

but would be good to make this a bit cleaner.

@antonmedv
Copy link
Member

But I think good naming required here. Maybe once?

task('only:once', function () {
....
})->once()

@alinalexandru
Copy link
Contributor Author

@antonmedv what do you think about this PR.
I am open to any feedback

@antonmedv
Copy link
Member

Merged!

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

No branches or pull requests

3 participants