executeSleep pauses execution
(action Action)
| 841 | |
| 842 | // executeSleep pauses execution |
| 843 | func (e *Executor) executeSleep(action Action) (string, error) { |
| 844 | duration, ok := action.Parameters["duration"].(string) |
| 845 | if !ok { |
| 846 | return "", fmt.Errorf("duration parameter required for sleep") |
| 847 | } |
| 848 | |
| 849 | d, err := time.ParseDuration(duration) |
| 850 | if err != nil { |
| 851 | return "", fmt.Errorf("invalid duration: %w", err) |
| 852 | } |
| 853 | |
| 854 | e.logInfo("Sleeping for %s", d) |
| 855 | time.Sleep(d) |
| 856 | return "slept", nil |
| 857 | } |
| 858 | |
| 859 | // fireAndForget is used for commands known to never produce output from the beacon. |
| 860 | // The API accepted the command and returned a task ID, so we just return a success message. |