DEV Community

Alexey Melezhik
Alexey Melezhik

Posted on

Sparrowdo - Ubiquitous Asynchronous Task Runner ( with Nice Frontend )

In the latest version of Sparrowdo I've improved "hosts" API allows one to define multiple tasks configurations using Raku Hashes and Arrays:

$ nano hosts.raku

[
  %( 
     host => "localhost",
     name => "task1",
     tags => %(
       param1 => "val1",
       param2 => "val2",
     )
  ),
  %( 
     host => "localhost",
     name => "task2",
     tags => %(
       param1 => "val1",
       param2 => "val2",
     )
  ),
]
Enter fullscreen mode Exit fullscreen mode

This trivial example defines 2 tasks get run with some specific parameters. To run these task we should to define a Sparrowdo scenario:

$ nano sparrowfile


say "you've passed me:";
say tags()<param1>;
say tags()<param2>;

# other task specific logic here

if tags()<name> eq "task1" {
 # ...
} elsif tags()<name> eq "task1" {
 # ...
}

Enter fullscreen mode Exit fullscreen mode

And run it:

$ sparrowdo --host=hosts.raku --sparrowfile=sparrowdo

Sparrowdo will put 2 tasks into a Sparky queue so that Sparky will handle them later in asynchronous way.

To track tasks statuses and reports - go to Sparky frontend - http://127.0.0.1:3000.

You can override some parameters using command line:

$ sparrowdo --host=hosts.raku --sparrowfile=sparrowdo --tags=param1=value100


Sparrowdo is all battery included Sparrow plugins and DSL one could use in their daily tasks:

$ nano hosts.raku

[
   %( 
     host => "192.168.0.1",
     tags => ["frontend","prod"]
   ),
   %( 
     host => "192.168.0.2",
     tags => ["backend","prod"]
   ),
]
Enter fullscreen mode Exit fullscreen mode

$ nano sparrowfile


if tags()<frontend> {
   package-install "nginx"
} elsif tags()<backend> {
   package-install "java"
} 
Enter fullscreen mode Exit fullscreen mode

Thanks for reading.

Alexey

Top comments (0)