azure-webjobs-sdk-extensions: Getting lots of "Unable to aquire Singleton lock" during localhost development

Heya šŸ˜ƒ

So Iā€™ve just started playing around / trying to use the TimerTrigger with a new webjob. Iā€™m doing localhost development to make sure the code works, before I deploy it up to Azure.

To do this, I click F5 to Debug my webjob console app. Ok, great! works/etcā€¦ I then stop this (or the code throws an exception and crashes).

I then change one tiny thing and then hit F5 again ā€¦ and then get this:

image

Sometimes, I wait 10 or even 20 seconds after the webjob stopped/stops and then hit F5 and still get that error.

Shouldnā€™t the host 100% tear down after itā€™s stopped? I should be able to hit F5, then close app, then hit F5 straight away, right?

Update / More info.

Hereā€™s my program.cs as a reference:

    class Program
    {
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();
            config.Tracing.ConsoleLevel = TraceLevel.Verbose;

            config.UseTimers();

            var host = new JobHost(config);
            host.RunAndBlock();

            //var host = new JobHost();
            //// The following code ensures that the WebJob will be running continuously
            //host.RunAndBlock();
        }
    }

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Ok, Iā€™ve added JobHostConfiguration.IsDevelopment and JobHostConfiguration.UseDevelopmentSettings(). You can see an example in the extensions sample here. This new method sets up all the optimal local dev settings as mentioned above.

See the xml doc on these new methods for details. Basically if your environment has a setting AzureWebJobsEnv, IsDevelopment will be true. Note that these changes are in prerelease packages available on myget.

The intent is for you NOT to have to discover anything about these low level details. It should just work for people

Iā€™m all for that šŸ˜ƒ Was just thinking about options, but yes! all for that šŸ˜ƒ

One option would be for the SDK to use a lower default lease period when running locally This I really like. But ā€¦ how do you define ā€˜locallyā€™ ? via the connection string?

e.g.: <Setting name="AzureConnectionString" value="UseDevelopmentStorage=true" />

However, this would work well for the ā€œgetting startedā€ case where a person is only running locally at the time. Thatā€™s the use case Iā€™m mainly targetting in this issue - so yep šŸ˜ƒ