Skip to content

Commit adbc837

Browse files
committed
sync doc with wiki
1 parent dcf32bd commit adbc837

6 files changed

+203
-103
lines changed

doc/Cloud-tips.md

+22
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,32 @@ the AWS x-ray daemon program on the server host by following [AWS X-Ray Daemon g
201201
All interactions between laitos and AWS generate info-level log messages for diagnosis and inspection.
202202

203203
## Deploy on Microsoft Azure and Google Compute Engine
204+
204205
Simply copy laitos program and its data onto a Linux virtual machine and start laitos right away. It is often useful to
205206
use systemd integration to launch laitos automatically upon system boot. All flavours of Linux distributions supported
206207
by Azure can run laitos.
207208

209+
## Deploy on Google App Engine
210+
211+
Clone the laitos repository and create a sub-directory named
212+
`gcp_appengine_data`. Place the following files into the sub-directory:
213+
214+
- `daemonName` - A plain-text file of comma-separated daemon names to be started
215+
on App Engine. The content is analogous to CLI parameter `-daemons`.
216+
- `appeng-environment.yaml` - A YAML file of program environment variables,
217+
for example: `env_variables:\n LAITOS_INDEX_PAGE: "{...}"`
218+
- `config.json` - A JSON file for the laitos program configuration.
219+
* Alternatively, write the program configuration JSON into the environment
220+
variable `LAITOS_CONFIG`.
221+
- Other program data files such as HTML assets.
222+
223+
Then navigate to the cloned directory (`laitos.git`) and run `gcloud app depoy`.
224+
225+
You can find an example in: https://github.com/HouzuoGuo/laitos/tree/master/gcp_appengine_data.example
226+
227+
Note that, the example config file is named `config.json.example` whereas the
228+
actual config file must be named `config.json`.
229+
208230
## Deploy on other cloud providers
209231
laitos runs on nearly all flavours of Linux system, therefore as long as your cloud provider supports Linux compute
210232
instance, you can be almost certain that it will run laitos smoothly and well.

doc/Get-started.md

+75-45
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
# Get started
22

3-
## Acquire software
4-
Download the latest [laitos software](https://github.com/HouzuoGuo/laitos/releases).
3+
## Obtain laitos software
54

6-
For geekier scenarios, use the latest go compiler to compile the software from source code like so:
5+
Download the latest laitos software from the [releases page](https://github.com/HouzuoGuo/laitos/releases).
76

8-
~/go > go get github.com/HouzuoGuo/laitos
9-
~/go/src/github.com/HouzuoGuo/laitos > go build
7+
Alternatively, compile the software manually by cloning this repository and then
8+
run `go build`.
109

11-
laitos is an all-in-one solution and does not depend on third party library.
10+
## Craft your configuration
11+
12+
A configurable laitos component belongs to one of the three categories:
1213

13-
## Prepare configuration
14-
laitos components go into three categories:
1514
- Apps - reading news and Emails, make a Tweet, ask about weather, etc.
16-
- Daemons - web/mail/DNS servers, chat bots, etc. Many daemons offer access to apps, protected with a password.
17-
- Rich web services - useful web-based utilities hosted by the web server.
15+
* Some apps do not require manual configuration and they are pre-enabled.
16+
- Daemons - web/mail/DNS servers, chat bots, etc. Many daemons are capable of
17+
accepting app command input and allow command execution protected by a
18+
password.
19+
- Web services - HTML-based utilities, web-hooks for integration with 3rd party
20+
services, etc.
1821

19-
Follow the links in [component list](https://github.com/HouzuoGuo/laitos/wiki/Component-list) to craft your very own
20-
configuration in [JSON](https://en.wikipedia.org/wiki/JSON).
21-
Keep in mind - nearly all components require configuration to be useful.
22+
Follow the links in [component list](https://github.com/HouzuoGuo/laitos/wiki/Component-list)
23+
to craft your very own configuration in [JSON](https://en.wikipedia.org/wiki/JSON).
2224

23-
As an example, here we use laitos DNS server for a safer and ad-free web experience at home, and automatically keep
24-
the laitos server computer up-to-date with latest security patches:
25+
As an example, here we use laitos DNS server to provide a safer and ad-free web
26+
experience at home, and enable a couple of web utilities:
2527

2628
{
2729
"DNSDaemon": {
@@ -30,14 +32,20 @@ the laitos server computer up-to-date with latest security patches:
3032
"10."
3133
]
3234
},
33-
"Maintenance": {
34-
"Recipients": [
35-
36-
]
37-
},
35+
"HTTPDaemon": {},
36+
"HTTPHandlers": {
37+
"CommandFormEndpoint": "/cmd",
38+
"FileUploadEndpoint": "/upload",
39+
"InformationEndpoint": "/info",
40+
"LatestRequestsInspectorEndpoint": "/latest_requests",
41+
"ProcessExplorerEndpoint": "/proc",
42+
"RequestInspectorEndpoint": "/myrequest",
43+
"WebProxyEndpoint": "/proxy"
44+
}
3845
}
3946

40-
## Start program
47+
## Start the program
48+
4149
Assume that latios software is in current directory, run the following command:
4250

4351
sudo ./laitos -config <PATH TO JSON FILE> -daemons <LIST>
@@ -60,25 +68,62 @@ Note that:
6068
* [`maintenance`](https://github.com/HouzuoGuo/laitos/wiki/%5BDaemon%5D-system-maintenance) - Automated server maintenance and program health report
6169
- Apps are enabled automatically once they are configured in the JSON file. Some apps such as the RSS News Reader are automatically enabled via their built-in default configuration.
6270

71+
## Other deployment techniques
72+
73+
### Use environment variables to feed the program configuration
74+
75+
For ease of deployment, laitos can fetch its program configuration along with
76+
the content of HTTP daemon index page from environment variables - instead of
77+
the usual files.
78+
79+
When `LAITOS_CONFIG` environment variable is present and not empty, laitos
80+
program will load its configuration from there. When `LAITOS_INDEX_PAGE`
81+
environment variable is present and not empty, laitos will use its content
82+
to serve the index page on its HTTP servers.
83+
84+
Check out environment variable usage examples in the [Kubernetes example](https://github.com/HouzuoGuo/laitos/blob/master/k8s.example/laitos-in-k8s.yaml)
85+
and the [example in Dockerfile](https://github.com/HouzuoGuo/laitos/blob/master/Dockerfile)
86+
87+
Be aware that the combined size of all environment variables generally cannot
88+
exceed ~2MBytes.
89+
90+
### Build a container image
91+
The images of a (usually) up-to-date version of laitos are uploaded to Docker
92+
Hub [hzgl/laitos](https://hub.docker.com/r/hzgl/laitos).
93+
94+
If you wish to customise the image to your needs, feel free to use the [`Dockerfile`](https://github.com/HouzuoGuo/laitos/blob/master/Dockerfile)
95+
from GitHub repository as a reference.
96+
6397
## Deploy on cloud
98+
6499
laitos runs well on all popular cloud vendors, it supports cloud virtual machines for a straight-forward installation,
65100
as well as more advanced cloud features such as AWS Elastic Beanstalk and AWS Lambda (in combination with API gateway).
66101
Check out the [cloud deployment tips](https://github.com/HouzuoGuo/laitos/wiki/Cloud-tips).
67102

68103
## Deploy on Windows
104+
69105
laitos is well tuned for running on Windows server and desktop. Check out this [PowerShell script](https://raw.githubusercontent.com/HouzuoGuo/laitos/master/extra/windows/setup.ps1)
70106
that helps to start laitos automatically as a background service.
71107

72-
## Advanced behaviours
108+
## Advanced program behaviours
109+
73110
### Self-healing
74-
laitos is extremely reliable thanks to its many built-in mechanisms that activate automatically in the unlikely event of program anormaly.
75-
The mechanisms are fully automatic and do not require manual intervention:
76111

77-
1. Access to external resources, such as API services on the public Internet, automatically recover from transient errors.
78-
2. Each daemon automatically restarts in case of a transient initialisation error, such as when required system resource is unavailable.
79-
3. laitos program and its daemons restart automatically in case of a complete program crash.
80-
4. In the extremely unlikely event of repeated program crashes in short succession (20 minutes), laitos will restart automatically while
81-
shedding of its daemons starting from the heaviest daemon, thus ensuring the maximum availabily of remaining healthy daemons.
112+
laitos is extremely reliable thanks to its many built-in mechanisms that make
113+
automated attempts to restart and isolate faulty components. The built-in
114+
mechanisms are fully automatic and do not require intervention:
115+
116+
1. Automatically recover from transient errors when contacting external
117+
resources, such as API services on the public Internet.
118+
2. Every daemon automatically restarts in case of a transient initialisation
119+
error.
120+
3. In the unlikely event of a program crash, the laitos program automatically
121+
restarts itself to recover.
122+
4. In the extremely unlikely event of repeated program crashes in short
123+
succession (20 minutes), laitos will attempt to automatically isolate the
124+
faulty daemon by removing daemons before the next restart - shedding the
125+
heavier daemons (e.g. DNS) first before shedding the lighter daemons (e.g.
126+
HTTP daemon).
82127

83128
Optionally, laitos can send server owner a notification mail when a program crash occurs. To enable the notification, follow
84129
[outgoing mail configuration](https://github.com/HouzuoGuo/laitos/wiki/Outgoing-mail-configuration) and then specify Email recipients in
@@ -98,6 +143,7 @@ Please use [Github issues](https://github.com/HouzuoGuo/laitos/issues) to report
98143
output contain valuable clues for diagnosis - please retain them for an issue report.
99144

100145
### More command line options
146+
101147
Use the following command line options with extra care:
102148
<table>
103149
<tr>
@@ -166,19 +212,3 @@ Use the following command line options with extra care:
166212
</td>
167213
</tr>
168214
</table>
169-
170-
### Build a container image
171-
Images of a (usually) up-to-date version of laitos are uploaded to Docker Hub [hzgl/laitos](https://hub.docker.com/r/hzgl/laitos).
172-
173-
If you wish to customise the image to your needs, feel free to use the [`Dockerfile`](https://github.com/HouzuoGuo/laitos/blob/master/Dockerfile)
174-
from GitHub repository as a reference.
175-
176-
### Supply program configuration in an environment variable
177-
Usually, the program configuration is kept in a JSON file, the path of which is specified in the laitos launch command line (`-config my-laitos-config.json`).
178-
However, if the program configuration is short enough to fit into an environment variable, laitos can also get its configuration
179-
from there. This can be rather useful for testing a configuration snippet or starting a small number of daemons in a container.
180-
181-
The following example starts the HTTP daemon (without TLS) on the default port number (80), the web server comes with app-command runner endpoint:
182-
183-
sudo env 'LAITOS_CONFIG={"HTTPFilters": {"PINAndShortcuts": {"Passwords": ["abcdefgh"]},"LintText": {"MaxLength": 1000}},"HTTPHandlers": {"AppCommandEndpoint": "/cmd"}}' ./laitos -daemons insecurehttpd
184-
# Try running an app command: curl http://0.0.0.0:80/cmd?cmd=abcdefgh.sdate
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,60 @@
11
## Introduction
2-
Check server system health (such as memory usage), and issue controlling commands to the laitos program,
3-
such as locking and stopping the server daemons.
2+
3+
The app helps to inspect program and system status, including program logs,
4+
resource usage, and system load.
5+
6+
When invoked with certain action names, the app offers limited control over the
7+
life-cycle of the program itself (e.g. put it into an unrecoverable locked
8+
state).
49

510
## Configuration
11+
612
This app is always available for use and does not require configuration.
713

814
## Usage
9-
Use any capable laitos daemon to invoke the app:
15+
16+
Use any laitos daemon capable of executing app commands to invoke the app:
1017

1118
.e <action>
1219

13-
Where action can be:
14-
- `info` - Get program status such as current clock, memory usage, load, etc.
15-
- `log` - Get latest log entries of all kinds - information and warnings.
16-
- `warn` - Get latest warning log entries.
17-
- `stack` - Get the latest stack traces.
20+
These actions help to inspect the program and system status:
1821

19-
It may also be:
22+
- `info` - Get a program and system status report including info such as PID,
23+
system load, memory usage, etc.
24+
- `log` - Get the latest log entries of all kinds - information and warnings.
25+
- `warn` - Get the latest warning log entries.
26+
- `stack` - Get the latest stack traces.
2027
- `tune` - Automatically tune server kernel parameters for enhanced performance and security.
21-
- `lock` - Keep laitos program running, but disable all apps and daemons, All web server URLs will return
22-
status 200 (OK) and an error text. The only way to recover from this state is to restart laitos program manually.
23-
- `stop` - Crash the laitos program.
24-
- `kill` - Destroy (nearly) all directories and files, mounted and local, on the computer hosting laitos program.
25-
Consequently laitos program crashes soon and the host computer will need to be reinitialised.
28+
29+
These actions offer limited control over the life-cycle of the laitos program:
30+
31+
- `lock` - Disable app command execution and disable nearly all daemons with the
32+
exception of HTTP servers. Web server handlers will respond with status 200 OK
33+
without processing the incoming request.
34+
* The only way to recover from this state is to login to the host OS and
35+
manually end and then restart the laitos program.
36+
- `stop` - Cause the laitos program to crash with a panic.
37+
- `kill` - Erase all disks on the computer host for as long as its OS can
38+
endure, which effectively destroys all data on the computer running laitos.
39+
* The laitos program will eventually crash along with the host OS.
2640

2741
## Tips
28-
- In case that a load balancer periodically checks the health status of laitos by visiting its HTTP server, the checks
29-
will continue to succeed (indicating a healthy server) even after `lock` action is executed. This is intentional to
30-
prevent the load balancer from replacing the laitos program under lock-down with a healthy instance not under lock-down.
31-
- The `kill` action attempts to delete most of the files on disk (including those mounted on mount points), and wipes
32-
disk partitions with zeros. It cannot guarantee that the entire disk has been filled with zeros before the computer
33-
crashes.
34-
35-
About retrieving the log entries:
36-
- laitos keeps the most recent log entries and warning log entries in memory, totalling several hundreds entries. They
37-
are available for inspection on-demand. The host operating system or hosting platform may have held more log entries
38-
available for your inspection.
39-
- The warning log entries keep track of the most recent (about three dozens) repeating offenders and will not present
40-
their repeated offences for inspection. For example, when laitos server refuses 30 DNS clients from querying the server
41-
yet they keep on going, their IPs will only show up once in the recent warnings, until the server refuses another 30,
42-
different DNS clients from querying the server.
42+
43+
- The locked-down mode (after executing the `lock` action) does not stop the
44+
HTP servers because HTTP is often used for health check. By responding with
45+
status 200 OK the health check will continue to consider laitos program
46+
healthy. Without leaving HTTP servers running the health check may decide to
47+
restart laitos program which renders the `lock` action ineffective.
48+
- The `kill` action runs indefinitely for as long as the host OS stays online.
49+
It however cannot possibly guarantee that all disks are completely erased
50+
before the host OS inevitably crashes.
51+
52+
About the retrieval of log entries:
53+
54+
- laitos keeps the most recent log entries - warnings and information, buffered
55+
in memory. Please use the host operating system's facilities
56+
(e.g. `journalctl`) to inspect older log entries.
57+
- To prevent an individual source from spamming the server and generates and
58+
thus generate an exceeding quatity of warning logs, the logger will only log a
59+
single warning entry for each offender and then suppresses further entries
60+
from the same offender for a short period of time.

doc/[Daemon]-mail-server.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ any mail. For communication secrecy, the server supports StartTLS operation and
55
To reduce spam, the sender IPs are passed through these widely-used DNS-based blocklists:
66
- "b.barracudacentral.org",
77
- "bl.mailspike.net",
8-
- "bl.spamcop.net",
98
- "cbl.abuseat.org",
109
- "dnsbl-1.uceprotect.net",
1110
- "dnsbl-2.uceprotect.net",
@@ -16,7 +15,6 @@ To reduce spam, the sender IPs are passed through these widely-used DNS-based bl
1615
- "ix.dnsbl.manitu.net",
1716
- "noptr.spamrats.com",
1817
- "psbl.surriel.com",
19-
- "singular.ttk.pte.hu",
2018
- "spam.dnsbl.anonmails.de",
2119
- "spam.dnsbl.sorbs.net",
2220
- "spam.spamrats.com",
@@ -227,17 +225,25 @@ Here are couple of examples involving, assuming that laitos server is on `123.23
227225
Wait up to an hour for new DNS records to propagate through the Internet.
228226

229227
## Test
228+
230229
Send a test mail with subject, text, and attachments to any name under `MyDomains` (e.g. `[email protected]`). Wait
231230
a short moment, check the inbox on any of `ForwardTo` address (e.g. `[email protected]`), the test mail should arrive at
232231
all of the `ForwardTo` addresses.
233232

234-
Try invoking an app command - send laitos server a mail with arbitrary subject, and write down password PIN and app command
235-
in the content body. Look for the command response in a mail replied to the sender.
233+
To invoke an app command, compose a plain text email to laitos server using an
234+
arbitrary subject text, write down the password PIN and app command in the mail
235+
body, and send it to laitos server. A short moment later, the command execution
236+
result will be mailed back to the sender.
236237

237238
## Tips
239+
238240
- Occasionally your mail provider (such as Gmail) may consider legitimate mails forwarded by laitos as spam, therefore please
239241
check your spam folders regularly.
240242
- Many Internet domain names use [DMARC](https://en.wikipedia.org/wiki/DMARC) to protect their business from mail spoofing.
241243
Though laitos usually forwards the verbatim copy of incoming mail to you, DMARC makes an exception - laitos has to change
242244
the sender from `[email protected]` to `name@protected-domain-laitos-nodmarc-###.com` where hash is a random digit.
243-
Otherwise your mail provder will discard the mail silently - without a trace in spam folder.
245+
Otherwise your mail provider will discard the mail silently - without a trace in spam folder.
246+
- Some mail providers and clients (such as Gmail on the web) automatically
247+
attaches a plain-text copy of the rich-text mail content when sending it.
248+
When receiving this kind of mail, the laitos mail server will be smart enough
249+
to pick up the plain-text copy and look for app command to execute there.

0 commit comments

Comments
 (0)