Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler is not working #27

Closed
Cloudmersive opened this issue Jul 21, 2018 · 9 comments
Closed

Scheduler is not working #27

Cloudmersive opened this issue Jul 21, 2018 · 9 comments
Assignees
Labels
question Further information is requested

Comments

@Cloudmersive
Copy link

I tried making a scheduler in .NET Core 2.1 running on Windows Server 2016 with IIS, but unfortunately doesn't work. Here is the code:

services.AddScheduler(scheduler =>
            {
                scheduler.Schedule(
                    () =>
                    {
                        // Makes API Call
                    }
                )
                .EveryMinute();
            }

Expected: Works and calls API

Actual: Doesn't do anything

@jamesmh
Copy link
Owner

jamesmh commented Jul 21, 2018

I believe in IIS (using the reverse kestrel proxy module) the .Net core application doesn't actually "start" until the first http request comes in. So if you have no http requests that are hit (i.e. you are just trying to use the scheduler), it might be why your asp .net core app hasn't started yet.

Sounds like maybe you want to do this by building a console app or windows service?

I'm planning on adding some docs for these scenarios in the future.

Let me know if this helps!

@jamesmh jamesmh added the question Further information is requested label Jul 21, 2018
@jamesmh
Copy link
Owner

jamesmh commented Jul 21, 2018

Here's the link describing what I had just said.

Because ASP.NET Core apps run in a process separate from the IIS worker process, the module also handles process management. The module starts the process for the ASP.NET Core app when the first request arrives and restarts the app if it crashes.

@jamesmh
Copy link
Owner

jamesmh commented Jul 24, 2018

Closing - let me know if you need further aid.

@jamesmh jamesmh closed this as completed Jul 24, 2018
@Cloudmersive
Copy link
Author

This was helpful, thanks

@lzinga
Copy link

lzinga commented Jul 15, 2019

@jamesmh I have tried some different cases with this such as https://www.taithienbo.com/how-to-auto-start-and-keep-an-asp-net-core-web-application-and-keep-it-running-on-iis/ but I am still getting issues. The scheduler doesn't seem to run even though the IIS site should be running and not time out to always be open and running.

@jamesmh
Copy link
Owner

jamesmh commented Jul 15, 2019

No idea. What version of .NET Core, Coravel and IIS are you running?

Is this inproc or outofprocess hosting method?

@lzinga
Copy link

lzinga commented Jul 29, 2019

.NET Core - 2.2
Coravel - 2.5.1 (although just upgraded to 2.6.0 today, not sure if this would contain an update for this issue)
IIS - 8.5.9600.16384

This is indeed using hostingModel="inprocess". I have it log to a database when the IInvocable are registered and when the scheduled tasks run.
image

It is supposed to run every day at noon (although apparently noon is at 5 AM, but I think thats just something on my end). On 7/26 it registered it but didn't run it in the morning even though it was running since the day before. Then on 7/27 it ran all the scheduled tasks, then completely skips 7/28. Then finally on 7/29 it didn't run the tasks but registered the tasks after the scheduled time (I assume when someone visited the site at that time.)

@jamesmh
Copy link
Owner

jamesmh commented Jul 29, 2019

Sounds like IIS isn't using the "always running" option?

Try out this -> https://www.nickedeye.com/iis-keep-website-alive-always-running/

Let me know 👍

@alizorlu
Copy link

Hii,

I just got this error.
when i noticed i realized i didn't add dependency injection .

Now, add that
services.AddScheduler();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants