Scheduled Safe Restart

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Scheduled Safe Restart

andyb-2
Hi,

Could you tell me if it's possible to schedule a regular safe-restart of Jenkins? I have the safe-restart plugin which works fine, but I'd like to have Jenkins do a safe-restart over the weekend when it's generally idle. I looked at the command line interface but I can't use that as it requires either storing a password in a file or passing a password on the command line, neither of which is doable in our environment. Is there a way to schedule an automatic safe restart from within Jenkins? I guess the problem is that if it's a job the restart will block 'til the job itself is completed, causing a deadlock. Can anyone suggest a way to achieve this?

Thanks,
Andy

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

Daniel Beck
You can also use an SSH key for authentication with jenkins-cli.jar (configure the key in the Jenkins user configuration), so if "environment" refers to non-technical reasons, that would be an option.

Then there's the REST API. POST to /safeRestart to perform that action. For authentication, use the API key of the user account in Jenkins instead of a password.

If you use the Groovy plugin, you could create a job that performs safeRestart in a System Groovy build step with 'jenkins.model.Jenkins.instance.safeRestart()'. Schedule as you would any other job.

On 27.02.2014, at 11:18, AndyB <[hidden email]> wrote:

> Hi,
>
> Could you tell me if it's possible to schedule a regular safe-restart of Jenkins? I have the safe-restart plugin which works fine, but I'd like to have Jenkins do a safe-restart over the weekend when it's generally idle. I looked at the command line interface but I can't use that as it requires either storing a password in a file or passing a password on the command line, neither of which is doable in our environment. Is there a way to schedule an automatic safe restart from within Jenkins? I guess the problem is that if it's a job the restart will block 'til the job itself is completed, causing a deadlock. Can anyone suggest a way to achieve this?
>
> Thanks,
> Andy
>
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

Baptiste MATHUS-3
In reply to this post by andyb-2

Just out of curiosity, why do you want to automate that restart?

Le 27 févr. 2014 11:18, "AndyB" <[hidden email]> a écrit :
Hi,

Could you tell me if it's possible to schedule a regular safe-restart of Jenkins? I have the safe-restart plugin which works fine, but I'd like to have Jenkins do a safe-restart over the weekend when it's generally idle. I looked at the command line interface but I can't use that as it requires either storing a password in a file or passing a password on the command line, neither of which is doable in our environment. Is there a way to schedule an automatic safe restart from within Jenkins? I guess the problem is that if it's a job the restart will block 'til the job itself is completed, causing a deadlock. Can anyone suggest a way to achieve this?

Thanks,
Andy

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

andyb-2
In reply to this post by Daniel Beck

Hi Daniel,

Yes 'environment' refers to policies. Saving a key should be acceptable. I'll give that a go, thanks.  Re. creating a job to do this, I'll try that, but I suspect that the safe-restart waits for no jobs to be running (that's the whole point of it after all), so issuing from a job might not work.

Thanks
Andy

On Thursday, 27 February 2014 10:39:45 UTC, Daniel Beck wrote:
You can also use an SSH key for authentication with jenkins-cli.jar (configure the key in the Jenkins user configuration), so if "environment" refers to non-technical reasons, that would be an option.

Then there's the REST API. POST to /safeRestart to perform that action. For authentication, use the API key of the user account in Jenkins instead of a password.

If you use the Groovy plugin, you could create a job that performs safeRestart in a System Groovy build step with 'jenkins.model.Jenkins.instance.safeRestart()'. Schedule as you would any other job.

On 27.02.2014, at 11:18, AndyB <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Z7mJG4cIImcJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">andy....@...> wrote:

> Hi,
>
> Could you tell me if it's possible to schedule a regular safe-restart of Jenkins? I have the safe-restart plugin which works fine, but I'd like to have Jenkins do a safe-restart over the weekend when it's generally idle. I looked at the command line interface but I can't use that as it requires either storing a password in a file or passing a password on the command line, neither of which is doable in our environment. Is there a way to schedule an automatic safe restart from within Jenkins? I guess the problem is that if it's a job the restart will block 'til the job itself is completed, causing a deadlock. Can anyone suggest a way to achieve this?
>
> Thanks,
> Andy
>
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Z7mJG4cIImcJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">jenkinsci-use...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/groups/opt_out" target="_blank" onmousedown="this.href='https://groups.google.com/groups/opt_out';return true;" onclick="this.href='https://groups.google.com/groups/opt_out';return true;">https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

andyb-2
In reply to this post by Baptiste MATHUS-3

Hi Baptiste.

>Just out of curiosity, why do you want to automate that restart?

I find Jenkins slows down after running for awhile (a week or so) and a restart usually fixes this. I've used the monitoring plugin to try to identify issues but I haven't spotted anything other than response times slowly increasing over time. Forcing garbage collection etc., seem to help a little, but so far the best solution is simply to restart. If I can schedule that over the weekend that should work well.  But yes, you are correct to ask why I need to do this as it shouldn't really be required. I'll continue to try and track down the root cause, but in the meantime this should help.

Thanks
Andy


On Friday, 28 February 2014 07:41:08 UTC, Baptiste Mathus wrote:

Just out of curiosity, why do you want to automate that restart?

Le 27 févr. 2014 11:18, "AndyB" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-AXoPsFI02UJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">andy....@...> a écrit :
Hi,

Could you tell me if it's possible to schedule a regular safe-restart of Jenkins? I have the safe-restart plugin which works fine, but I'd like to have Jenkins do a safe-restart over the weekend when it's generally idle. I looked at the command line interface but I can't use that as it requires either storing a password in a file or passing a password on the command line, neither of which is doable in our environment. Is there a way to schedule an automatic safe restart from within Jenkins? I guess the problem is that if it's a job the restart will block 'til the job itself is completed, causing a deadlock. Can anyone suggest a way to achieve this?

Thanks,
Andy

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="-AXoPsFI02UJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">jenkinsci-use...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/groups/opt_out" target="_blank" onmousedown="this.href='https://groups.google.com/groups/opt_out';return true;" onclick="this.href='https://groups.google.com/groups/opt_out';return true;">https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

Daniel Beck
In reply to this post by andyb-2
The job starts before it issues the safe restart command (obviously), then it finishes, then Jenkins restarts. I've tested this before posting.

On 28.02.2014, at 13:48, AndyB <[hidden email]> wrote:

> I suspect that the safe-restart waits for no jobs to be running (that's the whole point of it after all), so issuing from a job might not work

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

andyb-2


>The job starts before it issues the safe restart command (obviously), then it finishes, then Jenkins restarts. I've tested this before posting. 

Sounds perfect, thanks for checking!

Andy

On Friday, 28 February 2014 20:15:53 UTC, Daniel Beck wrote:
The job starts before it issues the safe restart command (obviously), then it finishes, then Jenkins restarts. I've tested this before posting.

On 28.02.2014, at 13:48, AndyB <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="zlmTW-SJLpkJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">andy....@...> wrote:

> I suspect that the safe-restart waits for no jobs to be running (that's the whole point of it after all), so issuing from a job might not work

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Scheduled Safe Restart

Christian Willman
In reply to this post by Daniel Beck
Precisely what we do. Every morning we run a scheduled job to grab and install our master list of Jenkins plugins and then trigger a safeRestart via a System Groovy build step. Works like a charm and hasn't failed us in over six months.

One thing to watch out for: if your developers have a rogue job, perhaps one with a broken, never-ending test, then you might come in Monday morning to a Jenkins instance still stuck in quiet mode with a full build queue. The queue will persist a restart but it's not good, especially if other teams are relying on Jenkins to deploy to regions or perform critical tests over the weekend. If a team is guilty of preventing a restart then we move their job(s) to a purgatory until they fix the problem. You could also use the build timeout plugin I guess.

On Thursday, February 27, 2014 5:39:45 AM UTC-5, Daniel Beck wrote:
If you use the Groovy plugin, you could create a job that performs safeRestart in a System Groovy build step with 'jenkins.model.Jenkins.instance.safeRestart()'. Schedule as you would any other job.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.