Octopus Deploy Documentation

Restart server

Last updated

Restarting servers is typically the responsibility of the Operations team as restarting a machine requires elevated permissions. With a runbook, you can give developers the ability to restart a machine whenever they need. The auditing feature of Octopus Deploy records the identity of the person who initiated the run of the runbook so you can always see who did what and when.

Unlike most other runbooks, this type of operation needs to run on a worker machine instead of the machine that needs to be restarted. This is to ensure communication to the Tentacle isn't interrupted, as it would be when the machine restarts, which would result in a failed run of the runbook.

Create the runbook

  1. To create a runbook, navigate to Project ➜ Operations ➜ Runbooks ➜ Add Runbook.
  2. Give the runbook a name and click SAVE.
  4. Add a Run a script step
  5. Change the Execution Location to Run on a worker on behalf of each deployment target
  6. Select the role from the On Targets in Roles drop-down list.
  7. Select the radio button that corresponds with the language you're using:
Invoke-Command -ScriptBlock { Restart-Computer } -ComputerName #{Octopus.Machine.Name}
ssh #{Octopus.Machine.Name} sudo reboot

Need support? We're here to help.