diff --git a/constants/error.go b/constants/error.go index c375e01..341148c 100644 --- a/constants/error.go +++ b/constants/error.go @@ -3,3 +3,4 @@ package constants import "fmt" var ErrTaskDoesNotExist = fmt.Errorf("Task does not Exist") +var ErrTaskIsAlreadyRunning = fmt.Errorf("Task is Already Running") diff --git a/task/task.go b/task/task.go index 6e2ad61..f6c687c 100644 --- a/task/task.go +++ b/task/task.go @@ -17,6 +17,11 @@ func StartTask(conf config.Config, data types.TaskStart) error { taskMutex.Lock() defer taskMutex.Unlock() + _, ok := tasks[data.ID] + if ok { + return constants.ErrTaskIsAlreadyRunning + } + tasks[data.ID] = &types.Task{ ID: data.ID, Type: data.Type,