Skip to content
Snippets Groups Projects
Unverified Commit 0f733d2c authored by Victor Castell's avatar Victor Castell Committed by GitHub
Browse files

Merge pull request #592 from yvanoers/v2.x-autorun-job

Autorun job after create
parents 028f7322 ce17ae85
No related branches found
Tags v2.0.0-rc3
No related merge requests found
......@@ -225,6 +225,9 @@ func parseDescriptor(spec string) Schedule {
Month: all(months),
Dow: all(dow),
}
case "@manually":
return At(time.Time{})
}
const every = "@every "
......
......@@ -165,6 +165,11 @@ func (h *HTTPTransport) jobCreateOrUpdateHandler(c *gin.Context) {
return
}
// Immediately run the job if so requested
if _, exists := c.GetQuery("runoncreate"); exists {
h.agent.GRPCClient.RunJob(job.Name)
}
c.Header("Location", fmt.Sprintf("%s/%s", c.Request.RequestURI, job.Name))
renderJSON(c, http.StatusCreated, &job)
}
......
......@@ -65,6 +65,13 @@ paths:
required: true
schema:
$ref: "#/definitions/job"
- in: query
name: runoncreate
description: If present, regardless of any value, causes the job to be run immediately after being succesfully created or updated.
required: false
schema:
type: boolean
allowEmptyValue: true
responses:
201:
description: Successful response
......
......@@ -63,6 +63,7 @@ You may use one of several pre-defined schedules in place of a cron expression.
@daily (or @midnight) | Run once a day, midnight | 0 0 0 * * *
@hourly | Run once an hour, beginning of hour | 0 0 * * * *
@minutely | Run once a minute, beginning of minute | 0 * * * * *
@manually | Never runs | N/A
### Intervals
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment