@thesave/exec_command
v0.1.5
Published
A Jolie library to execute a command with arguments in a separate process.
Downloads
8
Maintainers
Readme
execCommand
A Jolie library to execute a command with arguments in a separate process in an asynchronous way.
It currently relies on the Process standard Java library and it is mainly an asynchronous/reactive take on the standard Jolie Exec library, where all commands are issued asynchronously and the user can monitor their execution by receiving messages from the standard output and error of the process, as well as the notification of its termination with the related exit code.
Usage Example
from @jolie.execCommand.main import ExecCommand
from console import Console
service main(){
inputPort IN {
location: "local"
oneWay: stdErr, stdOut, exitNotification
}
embed ExecCommand as ExecCommand
embed Console as Console
execution { concurrent }
init {
with( request ){
.args[#.args] = "ping"
.args[#.args] = "-c"
.args[#.args] = "5"
.args[#.args] = "localhost"
.stderrStreamOperation = "stdErr"
.stdoutStreamOperation = "stdOut"
.terminationOperation = "exitNotification"
}
start@ExecCommand( request )
}
main {
[ stdErr( message ) ]{
println@Console( "ERROR: " + message )()
}
[ stdOut( message ) ]{
println@Console( "STDOUT: " + message )()
}
[ exitNotification( exitCode ) ]{
println@Console( "Command terminated with exit code" + exitCode )()
exit
}
}
}
Roadmap
- [ ] support multiple process executions with correlation sets
- [ ] support process kill-signal via process ids