Score:0

Deployer task with $options?

ng flag

I'm using deployer (https://deployer.org/docs/6.x/tasks) to deploy my laravel application and it works like a charm. However, I want to make it more pretty. Why? Because I have background NodeJS processes running and at every deploy, they need to be restarted. Since there are 2 type of applications, the following is present in my deploy.php

task('post-deploy', [
    //'cron:install',
    'pm2:restart:qworker',
    'pm2:restart:echo',
    'cachetool:clear:opcache',
])->desc('After deploy tasks');

Now foir this to wotk, I had to make 2 tasks in recipes.php

desc('Restart QWorker');
task(
    'pm2:restart:qworker',
    function () {
        $option = get('pm2_qworker_name');

        run("pm2 restart ${option}");
    }
)->onHosts(getenv('SSH_HOST_1'));

desc('Restart Echo Servers');
task(
    'pm2:restart:echo',
    function () {
        $option = get('pm2_echo_name');

        run("pm2 restart ${option}");
    }
);

But I want to reduce this to one task only, but still being able to tell which process I wish to restart. My goal would look something like this in the deploy.php file

task('post-deploy', [
    //'cron:install',
    'pm2:restart --something',
    'pm2:restart --something2',
    'cachetool:clear:opcache',
])->desc('After deploy tasks');

Any ideas how to define this in recipes.php in only one task ?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.