1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-09-28 14:30:45 +00:00
Commit Graph

56 Commits

Author SHA1 Message Date
Oliver Giles
9862affd98 fix warnings under clang++ 2020-09-26 11:33:36 +12:00
Oliver Giles
39ca7e86cf replace websockets with sse and refactor
Large refactor that more closely aligns the codebase to the kj async
style, more clearly exposes an interface for functional testing and
removes cruft. There is a slight increase in coupling between the
Laminar and Http/Rpc classes, but this was always an issue, just until
now more obscured by the arbitrary pure virtual LaminarInterface class
(which has been removed in this change) and the previous lumping
together of all the async stuff in the Server class (which is now
more spread around the code according to function).

This change replaces the use of Websockets with Server Side Events
(SSE). They are simpler and more suitable for the publish-style messages
used by Laminar, and typically require less configuration of the
reverse proxy HTTP server.

Use of gmock is also removed, which eases testing in certain envs.

Resolves #90.
2019-10-05 20:06:35 +03:00
Oliver Giles
4a07e24da3 split server into http and rpc parts
this is initial preparation for a larger refactor
2019-09-27 20:50:46 +03:00
Oliver Giles
7b418a546c add uint typedef
Needed for musl
2019-07-04 12:28:33 +03:00
Oliver Giles
21ea5363a9 resolves #89: ignore unknown http query params 2019-04-15 06:54:21 +03:00
Oliver Giles
0c67d4c844 logging: strip full paths from __FILE__ at compile-time 2019-04-11 22:14:26 +03:00
Oliver Giles
210787a352 log endpoint: hint to reverse-proxy not to buffer
As discussed in #88, nginx will buffer the chunked transfer-encoding
unless the proxy_buffering directive is disabled, or the
X-Accel-Buffering header is set to no. Do the latter to reduce
configuration burden on frontend reverse-proxy setups.
2019-03-29 22:40:46 +03:00
Oliver Giles
bb81931ce9 regression fix: badge url
badge urls were returning 404 and an exception message since
cec4721e. Fixed by correctly extracting the job name from the
request URL
2019-03-08 08:20:41 +02:00
Oliver Giles
807901c719 additional fixes for #79: chunked http log
use correct sqlite column name
remove redundant code, tidy implementation
2019-02-17 22:51:11 +02:00
Oliver Giles
cec4721e52 resolves #79: serve logs over plain chunked http 2019-02-15 19:05:44 +02:00
Oliver Giles
31c64980f7 Catch exceptions in websockets and drop the connection 2018-12-30 08:26:58 +02:00
Oliver Giles
c0556b871b resolves #77: exit noisily on ::bind failure 2018-12-14 15:23:57 +02:00
Oliver Giles
7cee824cee resolves #67: laminarc list jobs
Implements the following laminarc commands:
- show-jobs
- show-running
- show-queued
- abort
2018-10-12 17:22:21 +03:00
Oliver Giles
fddaed02d6 remove some duplicated code in RpcImpl
Part of #49 refactor
2018-09-28 12:56:49 +03:00
Oliver Giles
18012a8d7a resolves #63: remove locks
Add an example to the User Manual for using flock instead
2018-09-28 12:43:46 +03:00
Oliver Giles
08b3f25a22 Replace boost/filesystem with kj/filesystem
Lose the boost dependency since recent versions of capnproto's kj
also provide a nice filesystem library. Take the opportunity to
refactor the Run object to become more than POD and to encapsulate
some of the functionality that was done in the Laminar class

Part of #49 refactor
2018-09-28 12:43:40 +03:00
Oliver Giles
132d40e6a3 resolves #50: badge url
Implements serving of an SVG badge at the url /badge/JOB.svg which
prettily shows the job's current status
2018-09-10 14:51:43 +03:00
Oliver Giles
8bcce4d5cc resolves #40: implement frontend sorting
This feature allows runs to be sorted by result, number, start time
or duration, in ascending or descending order, on the Job page. Request
is processed server-side so that the correct page division can be done.
Currently running jobs are not sorted.
2018-08-24 12:15:40 +03:00
Oliver Giles
a81492e5bc use kj's onChildExit mechanism
This reduces code and allows for more idiosyncratic use of Promises.
Requires latest capnproto git.

Part of #49 refactor
2018-08-03 14:36:24 +03:00
Oliver Giles
4ffc22c657 use promises to control job runs
This is a refactor that more cleanly uses the kj framework for handling
processes spawned by Runs. This obviates the workaround introduced back in
ff42dae7cc, and incidentally now requires c++14.

Part of #49 refactor
2018-07-20 17:40:56 +03:00
Oliver Giles
758b5f2e46 resolves #37: closed connection on large files
The old implementation slurped the whole artefact into memory, and
did not ensure it remained allocated beyond the first call to write().
The new implementation uses mmap and ensures the mapping lasts until
the file has been delivered
2018-07-06 13:18:04 +03:00
Oliver Giles
078e0e9882 improve websocket handling
The previous implementation meant that messages could get lost if
both sending and receiving were scheduled to be processed in the
same event loop cycle. This commit separates the two channels
more clearly, while still allowing the close event in the receive
side to cancel the whole pipeline

Part of #49 refactor
2018-07-06 12:33:04 +03:00
Oliver Giles
4c2aa2680f Implement websocket communication with kj-http
Now that capnp/kj provides http and websocket functions, replace
the excellent websocketpp library with the kj functions. This
removes a dependency and allows for more consistent idiomatic
code. Thanks websocketpp, it was great to have you along!

This should enable parts of the refactor described in #49
2018-06-30 20:34:56 +03:00
Oliver Giles
a0f586581d resolves #38: implement pagination for the job page 2018-06-01 14:51:34 +03:00
Oliver Giles
f1e4d10be3 resolves #36: queue/start/run 2018-05-12 17:56:56 +03:00
Oliver Giles
649caee297 resolves #30: job execution timeout
Add the ability to configure a timeout in seconds
after which a job run will be automatically aborted
2018-05-12 13:25:19 +03:00
Oliver Giles
ce81be85c7 resolves #48: custom css ineffectual behind reverse proxy
Caddy (and probably other webservers) add a Content-Type header
when one was not supplied by the application backend. Under Chromium,
the css file is not interpreted if the webserver delivers it with
Content-Type: text/plain, althugh it does work if no Content-Type
header is set. To prevent the frontend proxy from adding the wrong
header, set it correctly in the first place
2018-05-04 07:48:48 +03:00
Oliver Giles
216ecee7c5 resolves #34: watch for configuration changes
Reload the configuration if a change is detected
without requiring a server restart
2018-04-06 18:04:50 +03:00
Oliver Giles
a5d8b985f1 laminarc: replace start with run 2018-04-06 13:43:38 +03:00
Oliver Giles
4d2388c271 resolves #33: laminar start output should reference run number 2018-04-06 13:35:02 +03:00
Oliver Giles
9c256815e4 resolves #29: graceful shutdown
on SIGINT/SIGTERM:
1. stop accepting new connections
2. send SIGTERM to all child tasks
3. wait for processes to end
4. drop all websockets
2018-02-24 18:53:11 +02:00
Oliver Giles
3b267967cf resolves #31: exception thrown on bad file descriptor
Read or writes to bad file descriptors threw exceptions, just log
this instead. Also make sure that LaminarClients are removed from
the list of clients when a connection is aggressively dropped, and
add test
2018-01-27 13:11:40 +02:00
Oliver Giles
93b428529e webui may be modified with custom style.css 2017-12-29 11:14:20 +02:00
Oliver Giles
3129f0e73b fix pedantic compiler warnings 2017-12-21 08:19:45 +02:00
Oliver Giles
9e1a65ccee server: minor websocket client handler refactor
Now explicitly closed connections on the client side are
closed with a clean error code. This is motivated by upcoming
work to detect broken websockets and automatically reconnect
2017-12-16 18:21:33 +02:00
Oliver Giles
74443c292a Fix copyright years
This reverts commit 4e911756bc.

In addition, copyright years are now expressed in the form of
(year file added)-(year file last changed)
2017-12-09 12:21:34 +02:00
Oliver Giles
e371f8ca5a server: use regular char array as buffer
This approach finally solves the crash under hardened gentoo
discussed in #19
2017-12-07 18:28:12 +02:00
Oliver Giles
4c63cef7ac remove unnecessary attach() 2017-12-06 21:59:22 +02:00
Oliver Giles
272176a6a5 server: allocate a single buffer per file descriptor 2017-12-06 21:51:50 +02:00
Oliver Giles
b70e501d6d attempt to solve segfault under hardened gentoo
Can't reproduce this locally, but looks like using a std::string
as an arbitrary buffer is causing problems. See #19
2017-12-06 09:24:35 +02:00
Oliver Giles
9c92c5b514 don't leak file descriptors into runs 2017-12-04 20:31:23 +02:00
Oliver Giles
d91816097a resolves #19: laminard crashes under load
reading into a static buffer is a race condition that is only
manifested under load. There's no guarantee the clause in then()
will run before another task overwrites the buffer. Allocating
a local string is the only correct solution
2017-12-04 20:29:19 +02:00
Oliver Giles
576159d8e9 send correct Content-Type header for static resources 2017-10-31 20:07:12 +02:00
Oliver Giles
b7644494fc unlink unix sockets before binding 2017-08-15 08:33:15 +03:00
Oliver Giles
c12fb3f030 remove unnecessary default parameter 2017-08-12 15:10:06 +03:00
Oliver Giles
eda906b805 refactor: remove transport knowledge from Laminar class
Improve the boundary between RpcImpl and LaminarInterface such
that the Laminar class doesn't require any types from kj/async.h.
The necessary logic moved from Laminar to RpcImpl and the notification
now happens by abstract virtual callback instead of kj::Promise.
Also remove the fairly useless 'wait' RPC call and drop the wrappers
around kj::PromiseFulfillerPair
2017-08-10 08:25:20 +03:00
Oliver Giles
ab99af7ca7 implement general-purpose locks 2017-08-10 07:40:30 +03:00
Oliver Giles
3068180f8e give capnp ownership of process output fd
this fixes an intermittent issue (race condition?) where
the IoContext attempts to poll an already-closed fd
2017-07-31 08:53:50 +03:00
Oliver Giles
4e911756bc update copyright year 2016-07-25 15:00:49 +03:00
Oliver Giles
2ea27d46ed implement proper child cleanup 2016-07-25 14:59:45 +03:00