Update Quartz.NET Job DLL without Service Restart - quartz.net

I just started with Quartz.net and I have it running as a service. I created a Job and moved the resulting .dll to the Quartz folder and added a new entry to the jobs.xml file to kick it off every 3 seconds.
I updated the job .dll but it is in use by Quartz (or is locked).
Is it possible to update the .dll without restarting the Quartz service? If not what would happen to a long running job if I did stop/start the Quartz service?

You cannot update the job dll without restarting the service. Once the server has started it loads the the job dll and the loaded types stay in memory. This is how .NET runtime works. To achieve something like dynamic reloading you would need to use programmatically created app domains etc.
If you stop the scheduler you can pass a bool parameter whether to wait for jobs to complete first. Then you would be safe with jobs completing and no new ones would spawn meanwhile the scheduler is shutting down.

Related

The process cannot access the file because it is being used by another process. Jenkins Build

When we abort one of the Jenkins Job builds running on windows slave, and then try to retrigger, that new triggered build fails with below error:
The process cannot access the file because it is being used by another process.
while deleting the workspace.
Possibly when the build job was killed, some process that it spawned was not killed along with it, and that process was holding the file opened.
Often that process will finish running on its own and when it does finish, the lock on the file will be released.
If the process does not go away on its own (for example, if it has opened a window such as the popup you see when a process crashes - and you would not be able to see such window running in the Jenkins service session) and you have access to the slave machine, you can log into it and use a tool like SystemInternals's Process Explorer (available at https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) to find and kill the process. ProcExp is a pretty easy tool to use, is reasonably well known, and great for situations like this.
If you do not have access, you may have to ask the SysAdmins to reboot the slave - it's very likely overkill but if you don't have access to the slave the people you have to ask for help will likely not have much time to help with debugging.
This error may occur due to the performance issue, in such cases we just need to use a loop like to avoid this, because, the current thread has to close before accessing by another process.
You can use the given method to access the file to attach with mail as follows:
using(Attachment attpath = new Attachment(filepath))
{
//your code to access the attached filepath
mail.Attachment(attpath);
}

How can I incorporate a long delay into a Jenkins build process?

I am using Jenkins to deploy changes to a system which manages and runs lots of different jobs which are scheduled daily. We have a staging setup which does not write to the real database, and a production setup which does.
The Jenkins flow I would like to have a happen when a change is pushed is this
Run checks.
Deploy to the staging system.
Wait 24 hours.
Check logs to make sure that the staging system has not had any errors in the last 24 hours.
Deploy to the production system.
There could be more than one of these builds running concurrently at any time - eg. I push changes at 11 am, they are deployed to staging. At 5 pm I push more changes and they are also deployed to staging. The next day at 11 am the first set of changes only are deployed to prod. At 5pm that day the second set of changes are deployed.
Now, I have managed to build a system which does this, by using the Build Flow Plugin, and creating a job called wait_one_day which runs sleep $((24 * 60 * 60)) in a bash shell.
This doesn't seem like the most elegant solution, and has the disadvantage that I am tying up two Build Executors for 24 hours (one for the build flow job, and one for wait_one_day), each time we make a change.
Is there any better way of doing this, or any plugin which is designed to help with this process? Can a Jenkins job schedule another Jenkins job to run as a one-off?
I would equally be happy to hear about an alternative approach to solve the same problem if anyone has any suggestions or constructive criticism of my design.
There was similar SO question recently that I answered, although I'm not sure that my answer there exactly fits your scenario.
You could potentially dynamically create a job that does steps 4 & 5 which would run periodically every 24 hours. The catch here is that you would actually only run this job once, and have a build step in that job that deletes itself (groovy code or shell script). It would be easy enough to create a deactivated template job that you could just clone and then modify for the particular task. An intermediary job would be necessary which would trigger upon completion of any job that runs steps 1 and 2. The intermediary job would then create the temporary job from the template.
Alternatively, you could create some sort of handler, either within jenkins or external that would run off of some properties file or database containing the scheduling for when jobs need to be fired off. Granted, if you are going to go the route of writing a handler, you might consider putting in a little extra effort and writing a jenkins plugin...

run automatically

Is it possible to run a part of code automatically in asp.net or mvc at special time. for example send mail to a group pf users exactly at 8 in the morning ( only by server and not by user)
No, but there are a few ways you could do it:
Quartz.net
A powershell script (which calls into the code you want to run) and job scheduler
A console application (which exposes and calls the code you want to run) and job scheduler

How can I configure execution start between dependent jobs?

My Jenkins server is set up with two jobs A and B say.
Job A is triggered from changes in subversion, runs unit tests and if successful, creates a WAR and deploys it to another environment.
If Job A succeeds, then Job B triggers. This job runs tests against the deployed WAR.
The problem is that the deployment process takes a while and the WAR is not ready in time for when Job B starts and tries to use it.
I'm looking for ideas on how to delay Job B until the WAR is up and running.
Is there a way, once Job B is triggered to wait for x seconds? I really don't want to put it into the tests in Job B if I can avoid it.
Thanks
There is definitely a way for a job to wait - just put sleep into the first shell build step. Alternatively, you can set 'Quiet period' - it's in Advanced Project Options when you create a build.
That, however, is a band-aid solution to be employed only if other approaches fail. You may try the following: if there is a way to make the deployment process (that job A triggers) right before it finishes to touch a file that Jenkins has access to, then you can use FSTrigger Plugin. See use case 3 there.
The most reliable way to make this work would be to make job A not complete until the deployment is successful, e.g. by testing for a valid response from the URL of the deployed web app. This blog post describes one way to do that.

Timer Jobs don't run after changing the schedule

I created a custom timer job. It used to run fine during development an initial testing when I using SPMinutSchedule for scheduling it every minute of 5 minutes. The intention is to run it once a day in production. So, I changed the schedule using SPDailySchedule and it stopped running. I kind of fixed it by clearing the cache of the server each time I change the schedule.
I deploy the job using a feature with Web Application scope.
Am I missing something here?
From REF: http://www.mstechblogs.com/shailaja/reschedule-or-change-the-interval-of-a-sharepoint-custom-timer-job/
To reschedule or change the interval of a SharePoint custom Timer Job
Change the schedule interval in the custom code using the
SPDailySchedule class of the SharePoint object model
Build and deploy in the GAC.
IISRESET
Go to the command prompt and navigate to the 12 hive of SharePoint
Uninstall the existing Timer feature, for example, stsadm.exe –o uninstallfeature –filename yourfeaturename\feature.xml
Install the new Timer feature, for example, stsadm.exe –o installfeature –filename yourfeaturename\feature.xml
Go to the windows services and restart the Windows SharePoint Services Timer

Resources