nrempel / adonis-scheduler Goto Github PK
View Code? Open in Web Editor NEWThis library provides an easy way to schedule recurring tasks for AdonisJS.
License: MIT License
This library provides an easy way to schedule recurring tasks for AdonisJS.
License: MIT License
I'm trying to run the scheduler using Adonis 4.1 and I'm getting this error.
adonis run:scheduler
RuntimeException: E_INVALID_SERVICE_PROVIDER: SchedulerProvider must extend base service provider class
> More details: https://err.sh/adonisjs/errors/E_INVALID_SERVICE_PROVIDER
1 Function.invoke
.../node_modules/@adonisjs/fold/node_modules/@adonisjs/generic-exceptions/src/RuntimeException.js:102
2 _.uniq.map
.../node_modules/@adonisjs/fold/src/Registrar/index.js:107
3 arrayMap
.../node_modules/lodash/lodash.js:639
4 Function.map
.../node_modules/lodash/lodash.js:9554
5 interceptor
.../node_modules/lodash/lodash.js:16997
6 thru
.../node_modules/lodash/lodash.js:8795
7 anonymous
.../node_modules/lodash/lodash.js:4368
8 arrayReduce
.../node_modules/lodash/lodash.js:683
9 baseWrapperValue
.../node_modules/lodash/lodash.js:4367
10 LazyWrapper.lazyValue [as value]
.../node_modules/lodash/lodash.js:1859
11 baseWrapperValue
.../node_modules/lodash/lodash.js:4365
12 LodashWrapper.wrapperValue
.../node_modules/lodash/lodash.js:9050
13 Registrar._getProvidersInstance
.../node_modules/@adonisjs/fold/src/Registrar/index.js:111
14 Registrar.providers
.../node_modules/@adonisjs/fold/src/Registrar/index.js:167
15 Ignitor._registerProviders
.../node_modules/@adonisjs/ignitor/src/Ignitor/index.js:269
16 Ignitor.fire
.../node_modules/@adonisjs/ignitor/src/Ignitor/index.js:760
Please explain how to use adonis WS ( websockets ) to push data using this scheduler i got this error
Ws
.getChannel('channel:*')
.topic('channel:XYZ')
.broadcast('message', 'Message for socket')
TypeError: Cannot read property 'broadcast' of null
at curl.setHeaders.get.then
How do I run the run:schedule
command when the Dyno boots up / restarts?
Haven't tried it.
But by looking the example file https://github.com/nrempel/adonis-scheduler/blob/master/examples/app/Tasks/Example.js#L13 and the code, the handle
method is a static property on the class, which simply defeats the purpose of creating a class.
I would suggest to make it an instance property and make
the task class instance using Ioc.make
on this line https://github.com/nrempel/adonis-scheduler/blob/master/src/Scheduler/index.js#L40.
Ioc.make
will create an instance of class and will inject any dependencies that class wants. For example.
class RemoveDisabledUsers {
static get schedule() {
return '*/1 * * * *';
}
static get inject () {
return ['App/Model/User']
}
constructor (User) {
this.User = User
}
* handle () {
const removeUsers = yield this.User.query().where('status', 'disabled').delete()
}
}
module.exports = RemoveDisabledUsers;
Above one is more helpful than having the static handle
, coz I am able to inject my dependencies automatically.
Also wrap your handle
method inside co. Which simply stays in the eco-system of AdonisJs by offering ES2015
generators first approach.
How can I make a such a work around like this
static get schedule() {
return "0 */1 * * * *";
}
When upgrading Adonis to version 5.0.12, the task logs show the following error:
info: [object Object] {"meta":"<message>"}
If someone has an idea that can be or how to solve it, you would be very grateful.
Well, The title says it all. I'm using adonis 4.1
If a non-js file is in the app/Tasks
directory scheduler tries to parse it and throws E_INVALID_TASK_SCHEDULE
The obvious solution is don't put non-js files in there, but In my case I have a .gitkeep
file in there and in the future I'll possibly have an .eslintrc
file in there.
I'm using Adonis3.2. I can't seem to make the library start. It's giving me this error when I'm typing ./ace:
SyntaxError: Unexpected identifier
../node_modules/adonis-scheduler/providers/SchedulerProvider.js (../node_modules/adonis-scheduler/providers/SchedulerProvider.js:1:1)
I added everything in the bootstrap/app.js file that was described, but can't make it work. Is 3.0.0 the right version for Adonis 3.2 ?
Closing for now, feel free to re-open if there are any issues.
Originally posted by @nrempel in #3 (comment)
How is the "adonis run: scheduler" command registered in the crontab of an Ubuntu operating system?
Package version:
AdonisJs 4.1
Node.js and npm version:
Node js 10.0.1
Npm 3.0
I need to run this task in production
When start with timezone America/Sao_Paulo in server, sheduler get timezone UTC.
I need execute sheduler in Brazil timezone. How To ?
I couldn't run migration. The console throw the following error:
Error: Make sure CommandsProvider extends the base command
1 Kernel.addCommand
/Users/juraboonnom/repo/EkoHBD/node_modules/@adonisjs/ace/src/Kernel/index.js:189
2 commands.forEach
/Users/juraboonnom/repo/EkoHBD/node_modules/@adonisjs/ignitor/src/Ignitor/index.js:412
3 Ignitor._registerCommands
/Users/juraboonnom/repo/EkoHBD/node_modules/@adonisjs/ignitor/src/Ignitor/index.js:412
4 Ignitor.fire
/Users/juraboonnom/repo/EkoHBD/node_modules/@adonisjs/ignitor/src/Ignitor/index.js:754
The I try commenting out the
const commands = [
// 'adonis-scheduler/providers/CommandsProvider'
]
on the app.js, the migration can be run, but the process does not exit. Hence I couldn't do things like node ace migration:run --force && npm start
.
scheduler running fine
i'm trying to attach to a Event in the end of task
but never catch in bootstrap/event.js
Hi,
there is a typo in Run.js:
'user strict';
should be
'use strict';
And in my case handle should only work with co()... But this can be an app specific problem..
It seems that using the Adonis Logger facility is not working inside of tasks.
const Logger = use('Logger')
Logger.info('log') // Does not print to console
@ntvsx193 I noticed that you set up logging so that you can do this.info('log')
. What was the motivation for this? Is it possible to have both this.info
and Logger.info
work?
I haven't had time to dig into it yet but I'll try and take a look this weekend.
Hi,
can I run adonisjs-scheduler as service with pm2?
or how to run scheduler on application start
regards,
Arwani
This package does not seem to be maintained anymore.
For people who are looking for a reliable alternative, I suggest you take a look at Adonis-Bull.
Hi,
How to start scheduler when I type the command adonis serve --dev
for example?
Thank you!
How can I run the tasks without the ./ace command?
The idea is that I want to make it dependent on an env variable tu run it automatically, without having to type in the command.
Due to the several Tasks that should execute to fulfill several aspects of our application, I desired a clean way of organizing our tasks.
In this light, decided to go with organizing similar tasks into subdirectories, only to discover that any task placed in a child directory/subdirectory(e.g. app/tasks/user/SendBirthdayWishes.js
) aren't loaded into the scheduler.
Diving into the source code, I discovered that adonis-scheduler
picks up only tasks placed directly(one-level down) in app/Tasks
alone.
As a solution, we could get all the tasks placed in app/tasks/**/**
recursively.
I could submit a PR for this if you desire.
Thanks.
I use adonis version 4.1.0, i had config in start/app.js
, when i run adonis make:task Example
it show this error error:
make:task is not a registered command
.
how to fix it?
how can call the task inside project when project be started ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.