Fossil SCM

fossil-scm / www / server / windows / service.md
1
# Fossil as a Windows Service
2
3
If you need Fossil to start automatically on Windows, it is suggested to install
4
Fossil as a Windows Service.
5
6
## Assumptions
7
8
1. You have Administrative access to a Windows 2012r2 or above server.
9
2. You have PowerShell 5.1 or above installed.
10
11
## Place Fossil on Server
12
13
However you obtained your copy of Fossil, it is recommended that you follow
14
Windows conventions and place it within `\Program Files\FossilSCM`, the
15
proper location for the official 64-bit binary.
16
This way Fossil is at an expected location and you will have minimal issues with
17
Windows interfering in your ability to run Fossil as a service. You will need
18
Administrative rights to place fossil at the recommended location. If you will
19
only be running Fossil as a service, you do not need to add this location to the
20
path, though you may do so if you wish.
21
22
## Installing Fossil as a Service
23
24
Luckily the hard work to use Fossil as a Windows Service has been done by the
25
Fossil team. We simply have to install it with the proper command line options.
26
Fossil on Windows has a command `fossil winsrv` to allow installing Fossil as a
27
service on Windows. This command is only documented on the windows executable
28
of Fossil. You must also run the command as administrator for it to be
29
successful.
30
31
### Fossil winsrv Example
32
33
The simplest form of the command is:
34
35
```
36
fossil winsrv create --repository D:/Path/to/Repo.fossil
37
```
38
39
This will create a windows service named 'Fossil-DSCM' running under the local
40
system account and accessible on port 8080 by default. `fossil winsrv` can also
41
start, stop, and delete the service. For all available options, please execute
42
`fossil help winsrv` on a windows install of Fossil.
43
44
If you wish to serve a directory of repositories, the `fossil winsrv` command
45
requires a slightly different set of options vs. `fossil server`:
46
47
```
48
fossil winsrv create --repository D:/Path/to/Repos --repolist
49
```
50
51
### Choice of Directory Considerations
52
53
When the Fossil server will be used at times that files may be locked
54
during virus scanning, it is prudent to arrange that its directory used
55
for temporary files is exempted from such scanning. Ordinarily, this
56
will be a subdirectory named "fossil" in the temporary directory given
57
by the Windows GetTempPath(...) API, [namely](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw#remarks)
58
the value of the first existing environment variable from `%TMP%`, `%TEMP%`,
59
`%USERPROFILE%`, and `%SystemRoot%`; you can look for their actual values in
60
your system by accessing the `/test-env` webpage.
61
Excluding this subdirectory will avoid certain rare failures where the
62
fossil.exe process is unable to use the directory normally during a scan.
63
64
### <a id='PowerShell'></a>Advanced service installation using PowerShell
65
66
As great as `fossil winsrv` is, it does not have one to one reflection of all of
67
the `fossil server` [options](/help/server). When you need to use some of
68
the more advanced options, such as `--https`, `--skin`, or `--extroot`, you will
69
need to use PowerShell to configure and install the Windows service.
70
71
PowerShell provides the [New-Service](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-service?view=powershell-5.1)
72
command, which we can use to install and configure Fossil as a service. The
73
below should all be entered as a single line in an Administrative PowerShell
74
console.
75
76
```PowerShell
77
New-Service -Name fossil -DisplayName fossil -BinaryPathName '"C:\Program Files\FossilSCM\fossil.exe" server --port 8080 --repolist "D:/Path/to/Repos"' -StartupType Automatic
78
```
79
80
Please note the use of forward slashes in the repolist path passed to Fossil.
81
Windows will accept either back slashes or forward slashes in path names, but
82
Fossil has a preference for forward slashes. The use of `--repolist` will make
83
this a multiple repository server. If you want to serve only a single
84
repository, then leave off the `--repolist` parameter and provide the full path
85
to the proper repository file. Other options are listed in the
86
[fossil server](/help/server) documentation.
87
88
The service will be installed by default to use the Local Service account.
89
Since Fossil only needs access to local files, this is fine and causes no
90
issues. The service will not be running once installed. You will need to start
91
it to proceed (the `-StartupType Automatic` parameter to `New-Service` will
92
result in the service auto-starting on boot). This can be done by entering
93
94
```PowerShell
95
Start-Service -Name fossil
96
```
97
98
in the PowerShell console.
99
100
Congratulations, you now have a base http accessible Fossil server running on
101
Windows.
102
103
### Removing the Windows Service
104
105
If you want to remove the Fossil service, execute the following from an
106
Administrative PowerShell or Command Prompt console:
107
108
```
109
sc.exe delete fossil
110
```
111
112
If you have Powershell version 6.0 or later, you can use:
113
114
```PowerShell
115
Remove-Service -Name fossil
116
```
117
118
with the same effect.
119
120
*[Return to the top-level Fossil server article.](../)*
121

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button