{"meta":{"title":"Configuring the self-hosted runner application as a service","intro":"You can configure the self-hosted runner application as a service to automatically start the runner application when the machine starts.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/how-tos","title":"How-tos"},{"href":"/en/actions/how-tos/manage-runners","title":"Manage runners"},{"href":"/en/actions/how-tos/manage-runners/self-hosted-runners","title":"Self-hosted runners"},{"href":"/en/actions/how-tos/manage-runners/self-hosted-runners/configure-the-application","title":"Configure the application"}],"documentType":"article"},"body":"# Configuring the self-hosted runner application as a service\n\nYou can configure the self-hosted runner application as a service to automatically start the runner application when the machine starts.\n\n<div class=\"ghd-tool linux\">\n\n> \\[!NOTE]\n> You must add a runner to GitHub before you can configure the self-hosted runner application as a service.\n> For more information, see [Adding self-hosted runners](/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners).\n\nFor Linux systems that use `systemd`, you can use the `svc.sh` script that is created after successfully adding the runner to install and manage using the application as a service.\n\nOn the runner machine, open a shell in the directory where you installed the self-hosted runner application. Use the commands below to install and manage the self-hosted runner service.\n\n</div>\n\n<div class=\"ghd-tool windows\">\n\n> \\[!NOTE]\n> Configuring the self-hosted runner application as a service on Windows is part of the application configuration process. If you have already configured the self-hosted runner application but did not choose to configure it as a service, you must remove the runner from GitHub and re-configure the application. When you re-configure the application, choose the option to configure the application as a service.\n>\n> For more information, see [Removing self-hosted runners](/en/actions/hosting-your-own-runners/managing-self-hosted-runners/removing-self-hosted-runners) and [Adding self-hosted runners](/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners).\n\nYou can manage the runner service in the Windows **Services** application, or you can use PowerShell to run the commands below.\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n> \\[!NOTE]\n> You must add a runner to GitHub before you can configure the self-hosted runner application as a service.\n> For more information, see [Adding self-hosted runners](/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners).\n\nOn the runner machine, open a shell in the directory where you installed the self-hosted runner application. Use the commands below to install and manage the self-hosted runner service.\n\n</div>\n\n<div class=\"ghd-tool linux\">\n\n## Installing the service\n\n1. Stop the self-hosted runner application if it is currently running.\n\n2. Install the service with the following command:\n\n   ```shell\n   sudo ./svc.sh install\n   ```\n\n3. Alternatively, the command takes an optional `user` argument to install the service as a different user.\n\n   ```shell\n   ./svc.sh install USERNAME\n   ```\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n## Installing the service\n\n1. Stop the self-hosted runner application if it is currently running.\n2. Install the service with the following command:\n\n   ```shell\n   ./svc.sh install\n   ```\n\n</div>\n\n## Starting the service\n\nStart the service with the following command:\n\n<div class=\"ghd-tool linux\">\n\n```shell\nsudo ./svc.sh start\n```\n\n> \\[!NOTE]\n> On Debian-based Linux systems (such as Debian or Ubuntu) with `needrestart` enabled, you can prevent `needrestart` from restarting the runner service during a workflow job by configuring it to ignore the runner service. Run the following command:\n>\n> ```bash\n> echo '$nrconf{override_rc}{qr(^actions\\.runner\\..+\\.service$)} = 0;' | sudo tee /etc/needrestart/conf.d/actions_runner_services.conf\n> ```\n\n</div>\n\n<div class=\"ghd-tool windows\">\n\n```shell\nStart-Service \"actions.runner.*\"\n```\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n```shell\n./svc.sh start\n```\n\n</div>\n\n## Checking the status of the service\n\nCheck the status of the service with the following command:\n\n<div class=\"ghd-tool linux\">\n\n```shell\nsudo ./svc.sh status\n```\n\n</div>\n\n<div class=\"ghd-tool windows\">\n\n```shell\nGet-Service \"actions.runner.*\"\n```\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n```shell\n./svc.sh status\n```\n\n</div>\n\nFor more information on viewing the status of your self-hosted runner, see [Monitoring and troubleshooting self-hosted runners](/en/actions/hosting-your-own-runners/managing-self-hosted-runners/monitoring-and-troubleshooting-self-hosted-runners).\n\n## Stopping the service\n\nStop the service with the following command:\n\n<div class=\"ghd-tool linux\">\n\n```shell\nsudo ./svc.sh stop\n```\n\n</div>\n\n<div class=\"ghd-tool windows\">\n\n```shell\nStop-Service \"actions.runner.*\"\n```\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n```shell\n./svc.sh stop\n```\n\n</div>\n\n## Uninstalling the service\n\n1. Stop the service if it is currently running.\n2. Uninstall the service with the following command:\n\n    <div class=\"ghd-tool linux\">\n\n   ```shell\n   sudo ./svc.sh uninstall\n   ```\n\n    </div>\n\n    <div class=\"ghd-tool windows\">\n\n   ```shell\n   Remove-Service \"actions.runner.*\"\n   ```\n\n    </div>\n\n    <div class=\"ghd-tool mac\">\n\n   ```shell\n   ./svc.sh uninstall\n   ```\n\n    </div>\n\n<div class=\"ghd-tool linux\">\n\n## Customizing the self-hosted runner service\n\nIf you don't want to use the above default `systemd` service configuration, you can create a customized service or use whichever service mechanism you prefer. Consider using the `serviced` template at `actions-runner/bin/actions.runner.service.template` as a reference. If you use a customized service, the self-hosted runner service must always be invoked using the `runsvc.sh` entry point.\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n## Customizing the self-hosted runner service\n\nIf you don't want to use the above default launchd service configuration, you can create a customized service or use whichever service mechanism you prefer. Consider using the `plist` template at `actions-runner/bin/actions.runner.plist.template` as a reference. If you use a customized service, the self-hosted runner service must always be invoked using the `runsvc.sh` entry point.\n\n</div>"}