3 homepage: https://git.rootprojects.org/root/serviceman
5 Serviceman: cross-platform service management for Linux, Mac, and Windows.
8 To update or switch versions, run `webi serviceman@stable`
12 > Serviceman is a hassle-free wrapper around your system launcher. It works with
13 > the default system launcher to make it easy to start _user_- and
14 > _system_-level services, such as webservers, backup scripts, network and
21 - The Registry (Windows)
23 Serviceman can run an app in just about any programming language very simply.
25 If you'd like to learn what `serviceman` does without actually making changes,
26 add the `--dryrun` option.
31 sudo env PATH="$PATH" serviceman add bash ./backup.sh /mnt/data
36 **Development Server**
41 sudo env PATH="$PATH" \
42 serviceman add --system --cap-net-bind \
43 npx nodemon ./server.js
51 sudo env PATH="$PATH" \
52 serviceman add --system --cap-net-bind \
59 pushd ./my-go-package/
61 sudo env PATH="$PATH" \
62 serviceman add --system \
63 go run -mod=vendor cmd/my-service/*.go --port 3000
67 pushd ./my-go-package/
68 go build -mod=vendor cmd/my-service
70 sudo env PATH="$PATH" \
71 serviceman add --cap-net-bind --system \
72 ./my-service --port 80
75 ### How to see all services
78 serviceman list --system
79 serviceman list --user
83 serviceman-managed services:
88 ### How to restart a service
90 You can either `add` the service again (which will update any changed options),
91 or you can `stop` and then `start` any service by its name:
94 sudo env PATH="$PATH" serviceman stop example-service
95 sudo env PATH="$PATH" serviceman start example-service
98 ## What a typical systemd .service file looks like
102 Description=example-service
103 After=network-online.target
104 Wants=network-online.target systemd-networkd-wait-online.service
108 StartLimitInterval=10
114 WorkingDirectory=/srv/example-service
115 ExecStart=/srv/example-service/bin/example-command start
116 ExecReload=/bin/kill -USR1 $MAINPID
118 # Allow the program to bind on privileged ports, such as 80 and 443
119 CapabilityBoundingSet=CAP_NET_BIND_SERVICE
120 AmbientCapabilities=CAP_NET_BIND_SERVICE
124 WantedBy=multi-user.target
127 ## What a typical launchd .plist file looks like
130 <?xml version="1.0" encoding="UTF-8"?>
131 <!-- Generated for serviceman. Edit as you wish, but leave this line. -->
132 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
133 <plist version="1.0">
136 <string>example-service</string>
137 <key>ProgramArguments</key>
139 <string>/Users/me/example-service/bin/example-command</string>
140 <string>start</string>
148 <key>WorkingDirectory</key>
149 <string>/Users/me/example-service</string>
151 <key>StandardErrorPath</key>
152 <string>/Users/me/.local/share/example-service/var/log/example-service.log</string>
153 <key>StandardOutPath</key>
154 <string>/Users/me/.local/share/example-service/var/log/example-service.log</string>
159 ### Use `--dryrun` to see the generated launcher config:
162 sudo env PATH="$PATH" \
163 serviceman add --system --dryrun \
164 bash ./backup.sh /mnt/data
167 ### See the (sub)command help
169 The main help, showing all subcommands:
175 Sub-command specific help:
178 serviceman add --help