code.gitea.io/gitea@v1.22.3/docs/content/installation/windows-service.en-us.md (about)

     1  ---
     2  date: "2016-12-21T15:00:00-02:00"
     3  title: "Register as a Windows service"
     4  slug: "windows-service"
     5  sidebar_position: 50
     6  toc: false
     7  draft: false
     8  aliases:
     9    - /en-us/windows-service
    10  menu:
    11    sidebar:
    12      parent: "installation"
    13      name: "Windows Service"
    14      sidebar_position: 50
    15      identifier: "windows-service"
    16  ---
    17  # Register as a Windows service
    18  
    19  ## Prerequisites
    20  
    21  The following changes are made in C:\gitea\custom\conf\app.ini:
    22  
    23  ```
    24  RUN_USER = COMPUTERNAME$
    25  ```
    26  
    27  Sets Gitea to run as the local system user.
    28  
    29  COMPUTERNAME is whatever the response is from `echo %COMPUTERNAME%` on the command line. If the response is `USER-PC` then `RUN_USER = USER-PC$`
    30  
    31  ### Use absolute paths
    32  
    33  If you use SQLite3, change the `PATH` to include the full path:
    34  
    35  ```
    36  [database]
    37  PATH     = c:/gitea/data/gitea.db
    38  ```
    39  
    40  ## Register Gitea
    41  
    42  To register Gitea as a Windows service, open a command prompt (cmd) as an Administrator,
    43  then run the following command:
    44  
    45  ```
    46  sc.exe create gitea start= auto binPath= "\"C:\gitea\gitea.exe\" web --config \"C:\gitea\custom\conf\app.ini\""
    47  ```
    48  
    49  Do not forget to replace `C:\gitea` with the correct Gitea directory.
    50  
    51  Open "Windows Services", search for the service named "gitea", right-click it and click on
    52  "Run". If everything is OK, Gitea will be reachable on `http://localhost:3000` (or the port
    53  that was configured).
    54  
    55  ### Service startup type
    56  
    57  It was observed that on loaded systems during boot Gitea service may fail to start with timeout records in Windows Event Log.
    58  In that case change startup type to `Automatic-Delayed`. This can be done during service creation, or by running config command
    59  
    60  ```
    61  sc.exe config gitea start= delayed-auto
    62  ```
    63  
    64  ### Adding startup dependencies
    65  
    66  To add a startup dependency to the Gitea Windows service (eg Mysql, Mariadb), as an Administrator, then run the following command:
    67  
    68  ```
    69  sc.exe config gitea depend= mariadb
    70  ```
    71  
    72  This will ensure that when the Windows machine restarts, the automatic starting of Gitea is postponed until the database is ready and thus mitigate failed startups.
    73  
    74  ## Unregister Gitea
    75  
    76  To unregister Gitea as a Windows service, open a command prompt (cmd) as an Administrator and run:
    77  
    78  ```
    79  sc.exe delete gitea
    80  ```