From 9e01cacf059925c371f522b6150760be90fb3ea7 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 4 Jul 2019 02:51:37 -0600 Subject: [PATCH] cleaning up docs --- README.md | 262 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 167 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 31dcf67..65e9e36 100644 --- a/README.md +++ b/README.md @@ -7,24 +7,21 @@ Because debugging launchctl, systemd, etc absolutely sucks! ...and I wanted a reasonable way to install [Telebit](https://telebit.io) on Windows. (see more in the **Why** section below) -
-User Mode Services - * `sytemctl --user` on Linux - * `launchctl` on MacOS - * `HKEY_CURRENT_USER/.../Run` on Windows -
-
-System Services - * `sudo sytemctl` on Linux - * `sudo launchctl` on MacOS - * _not yet implemented_ on Windows -
+## Features -## Contents +- Unprivileged (User Mode) Services + - [x] Linux (`sytemctl --user`) + - [x] MacOS (`launchctl`) + - [x] Windows (`HKEY_CURRENT_USER/.../Run`) +- Privileged (System) Services + - [x] Linux (`sudo sytemctl`) + - [x] MacOS (`sudo launchctl`) + - [ ] Windows (_not yet implemented_) + +# Table of Contents -- Install - Usage -- Build +- Install - Examples - compiled programs - scripts @@ -33,77 +30,145 @@ Because debugging launchctl, systemd, etc absolutely sucks! - python - ruby - Logging -- Windows - Debugging +- Windows +- Building - Why - Legal -# Install - -```bash -curl https://rootprojects.org/serviceman/dist/$GOOS/$GOARCH/serviceman -o serviceman -``` - -Download `serviceman` for - -- [MacOS (64-bit darwin)](https://rootprojects.org/serviceman/dist/darwin/amd64/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/darwin/amd64/serviceman -o serviceman - ``` -- [Windows 10 (64-bit)](https://rootprojects.org/serviceman/dist/windows/amd64/serviceman.exe) - ```console - powershell.exe Invoke-WebRequest https://rootprojects.org/serviceman/dist/windows/amd64/serviceman.exe -OutFile serviceman.exe - ``` -- [Windows 10 (32-bit)](https://rootprojects.org/serviceman/dist/windows/386/serviceman.exe) - ```console - powershell.exe Invoke-WebRequest https://rootprojects.org/serviceman/dist/windows/386/serviceman.exe -OutFile serviceman.exe - ``` -- [Linux (64-bit)](https://rootprojects.org/serviceman/dist/linux/amd64/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/linux/amd64/serviceman -o serviceman - ``` -- [Linux (32-bit)](https://rootprojects.org/serviceman/dist/linux/386/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/linux/386/serviceman -o serviceman - ``` -- [Raspberry Pi 4 (64-bit armv8)](https://rootprojects.org/serviceman/dist/linux/armv8/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/linux/armv8/serviceman -o serviceman - ``` -- [Raspberry Pi 3 (armv7)](https://rootprojects.org/serviceman/dist/linux/armv7/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/linux/armv7/serviceman -o serviceman - ``` -- [ARMv6](https://rootprojects.org/serviceman/dist/linux/armv6/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/linux/armv6/serviceman -o serviceman - ``` -- [Raspberry Pi Zero (armv5)](https://rootprojects.org/serviceman/dist/linux/armv5/serviceman) - ```bash - curl https://rootprojects.org/serviceman/dist/linux/armv5/serviceman -o serviceman - ``` - # Usage -```bash +``` serviceman add [options] [interpreter] -- [service options] ``` -```bash +``` +serviceman add foo.exe +``` + +``` +serviceman add --title "Foo App" node ./foo.js -- --bar +``` + +``` serviceman add --help ``` -```bash +``` serviceman version ``` +# Install + +There are a number of pre-built binaries. + +If none of them work for you, or you prefer to build from source, +see the instructions for building far down below. + +## Downloads + +### MacOS + +MacOS (darwin): [64-bit Download ](https://rootprojects.org/serviceman/dist/darwin/amd64/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/darwin/amd64/serviceman -o serviceman +``` + +### Windows + +
+See download options +Windows 10: [64-bit Download](https://rootprojects.org/serviceman/dist/windows/amd64/serviceman.exe) + +``` +powershell.exe Invoke-WebRequest https://rootprojects.org/serviceman/dist/windows/amd64/serviceman.exe -OutFile serviceman.exe +``` + +Windows 7: [32-bit Download](https://rootprojects.org/serviceman/dist/windows/386/serviceman.exe) + +``` +powershell.exe "(New-Object Net.WebClient).DownloadFile('https://rootprojects.org/serviceman/dist/windows/386/serviceman.exe', 'serviceman.exe')" +``` + +
+ +### Linux + +
+See download options + +Linux (64-bit): [Download](https://rootprojects.org/serviceman/dist/linux/amd64/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/linux/amd64/serviceman -o serviceman +``` + +Linux (32-bit): [Download](https://rootprojects.org/serviceman/dist/linux/386/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/linux/386/serviceman -o serviceman +``` + +
+ +### Raspberry Pi (Linux ARM) + +
+See download options + +RPi 4 (64-bit armv8): [Download](https://rootprojects.org/serviceman/dist/linux/armv8/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/linux/armv8/serviceman -o serviceman` +``` + +RPi 3 (armv7): [Download](https://rootprojects.org/serviceman/dist/linux/armv7/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/linux/armv7/serviceman -o serviceman +``` + +ARMv6: [Download](https://rootprojects.org/serviceman/dist/linux/armv6/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/linux/armv6/serviceman -o serviceman +``` + +RPi Zero (armv5): [Download](https://rootprojects.org/serviceman/dist/linux/armv5/serviceman) + +``` +curl https://rootprojects.org/serviceman/dist/linux/armv5/serviceman -o serviceman +``` + +
+ +### Add to PATH + +**Windows** + +``` +mkdir %userprofile%\bin +reg add HKEY_CURRENT_USER\Environment /v PATH /d "%PATH%;%userprofile%\bin" +move serviceman.exe %userprofile%\bin\serviceman.exe +``` + +**All Others** + +``` +sudo mv ./serviceman /usr/local/bin/ +``` + # Examples -**Compiled Apps** +> **serviceman add** <program> **--** <program options> -Normally you might run your program something like this: +
+Compiled Programs -```bash +Normally you might your program somewhat like this: + +``` dinglehopper --port 8421 ``` @@ -111,16 +176,9 @@ Adding a service for that program with `serviceman` would look like this: > **serviceman add** dinglehopper **--** --port 8421 -`serviceman` will find `dinglehopper` in your PATH, but if you have -any arguments with relative paths, you should switch to using absolute paths. +serviceman will find dinglehopper in your PATH. -```bash -dinglehopper --config ./conf.json -``` - -becomes - -> **serviceman add** dinglehopper **--** --config **/Users/aj/dinglehopper/conf.json** +
Using with scripts @@ -130,7 +188,7 @@ in order for `serviceman` to configure the service correctly. For example, if you had a bash script that you normally ran like this: -```bash +``` ./snarfblat.sh --port 8421 ``` @@ -148,7 +206,7 @@ An operating system can't "run" text files (even if the executable bit is set). Scripts require an _interpreter_. Often this is denoted at the top of "executable" scripts with something like one of these: -```bash +``` #!/usr/bin/env ruby ``` @@ -222,6 +280,20 @@ See **Using with scripts** for more detailed information.
+## Relative vs Absolute Paths + +Although serviceman can expand the executable's path, +if you have any arguments with relative paths +you should switch to using absolute paths. + +``` +dinglehopper --config ./conf.json +``` + +``` +serviceman add dinglehopper -- --config /Users/me/dinglehopper/conf.json +``` + # Logging When you run `serviceman add` it will either give you an error or @@ -249,22 +321,6 @@ If anything about the logging sucks, tell me... unless they're your logs That said, my goal is that it shouldn't take an IT genius to interpret why your app failed to start. -# Peculiarities of Windows - -Windows doesn't have a userspace daemon launcher. -This means that if your application crashes, it won't automatically restart. - -However, `serviceman` handles this by not directly adding your application -to `HKEY_CURRENT_USER/.../Run`, but rather installing a copy of _itself_ -instead, which runs your application and automatically restarts it whenever it -exits. - -If the application fails to start `serviceman` will retry continually, -but it does have an exponential backoff of up to 1 minute between failed -restart attempts. - -See the bit on `serviceman run` in the **Debugging** section down below for more information. - # Debugging One of the most irritating problems with all of these launchers is that they're @@ -293,7 +349,7 @@ Where `conf.json` looks something like ```json { "title": "Demo", - "exec": "/Users/aj/go-demo/demo", + "exec": "/Users/me/go-demo/demo", "argv": ["--foo", "bar", "--baz", "qux"] } ``` @@ -334,6 +390,22 @@ for Windows. If you have gripes about it, tell me. It shouldn't suck. That's the goal anyway. +## Peculiarities of Windows + +Windows doesn't have a userspace daemon launcher. +This means that if your application crashes, it won't automatically restart. + +However, `serviceman` handles this by not directly adding your application +to `HKEY_CURRENT_USER/.../Run`, but rather installing a copy of _itself_ +instead, which runs your application and automatically restarts it whenever it +exits. + +If the application fails to start `serviceman` will retry continually, +but it does have an exponential backoff of up to 1 minute between failed +restart attempts. + +See the bit on `serviceman run` in the **Debugging** section down below for more information. + # Building ```bash