aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
AgeCommit message (Collapse)AuthorLines
2026-07-06Minor modernizationsOliver Giles-6/+4
resolves #235
2023-11-07Support Clang/LLVM build on FBSDmarian cingel-2/+1
- Update CMakeList to support installation to PREFIX directory - FreeBSD does not support abstract sockets (unix-abstract:laminar), so explicit 'LAMINAR_BIND_RPC=IP:port' is required - ld.lld requires explicit emulation for binary blobs, add a new variable LINKER_EMULATION_FLAGS for this purpose
2021-12-24Revert "make taskFailed non-fatal"Oliver Giles-1/+3
Originally reverted to prevent a crash when reading from an http client raised ECONNRESET. Although this prevented a crash, laminar stopped listening for http connections. That issue was resolved in 37bbf6ade4 (see #164), so make all exceptions fatal again. This reverts commit 02810309fcfe09f1b4eb283625d656260d0690ef.
2021-12-24server: handle ECONNRESET in http connectionsOliver Giles-0/+8
In real deployments, sometimes http connections break with ECONNRESET. This causes the kj::HttpServer listener promise to break, which means no more connections are accepted. Catch this exception and restart the listener. resolves #164
2021-11-12create unix sockets with 660 permissionsOliver Giles-5/+12
Realistically this is probably the permission mask you want if you are using a unix socket for LAMINAR_BIND_RPC or LAMINAR_BIND_HTTP. resolves #160
2021-05-03make taskFailed non-fatalOliver Giles-3/+1
turns out we can end up here when an http client unexpectedly drops the connection, so it must not cause an exit()
2020-09-26fix warnings under clang++Oliver Giles-1/+1
2019-10-05replace websockets with sse and refactorOliver Giles-47/+50
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-09-27split server into http and rpc partsOliver Giles-456/+7
this is initial preparation for a larger refactor
2019-07-04add uint typedefOliver Giles-1/+1
Needed for musl
2019-04-15resolves #89: ignore unknown http query paramsOliver Giles-0/+12
2019-04-11logging: strip full paths from __FILE__ at compile-timeOliver Giles-1/+1
2019-03-29log endpoint: hint to reverse-proxy not to bufferOliver Giles-0/+2
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-08regression fix: badge urlOliver Giles-1/+1
badge urls were returning 404 and an exception message since cec4721e. Fixed by correctly extracting the job name from the request URL
2019-02-17additional fixes for #79: chunked http logOliver Giles-5/+4
use correct sqlite column name remove redundant code, tidy implementation
2019-02-15resolves #79: serve logs over plain chunked httpOliver Giles-9/+91
2018-12-30Catch exceptions in websockets and drop the connectionOliver Giles-0/+5
2018-12-14resolves #77: exit noisily on ::bind failureOliver Giles-3/+3
2018-10-12resolves #67: laminarc list jobsOliver Giles-2/+48
Implements the following laminarc commands: - show-jobs - show-running - show-queued - abort
2018-09-28remove some duplicated code in RpcImplOliver Giles-15/+12
Part of #49 refactor
2018-09-28resolves #63: remove locksOliver Giles-26/+0
Add an example to the User Manual for using flock instead
2018-09-28Replace boost/filesystem with kj/filesystemOliver Giles-5/+5
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-10resolves #50: badge urlOliver Giles-0/+6
Implements serving of an SVG badge at the url /badge/JOB.svg which prettily shows the job's current status
2018-08-24resolves #40: implement frontend sortingOliver Giles-3/+4
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-03use kj's onChildExit mechanismOliver Giles-23/+9
This reduces code and allows for more idiosyncratic use of Promises. Requires latest capnproto git. Part of #49 refactor
2018-07-20use promises to control job runsOliver Giles-2/+7
This is a refactor that more cleanly uses the kj framework for handling processes spawned by Runs. This obviates the workaround introduced back in ff42dae7cc3, and incidentally now requires c++14. Part of #49 refactor
2018-07-06resolves #37: closed connection on large filesOliver Giles-6/+5
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-06improve websocket handlingOliver Giles-16/+20
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-06-30Implement websocket communication with kj-httpOliver Giles-198/+140
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-01resolves #38: implement pagination for the job pageOliver Giles-5/+14
2018-05-12resolves #36: queue/start/runOliver Giles-6/+25
2018-05-12resolves #30: job execution timeoutOliver Giles-1/+7
Add the ability to configure a timeout in seconds after which a job run will be automatically aborted
2018-05-04resolves #48: custom css ineffectual behind reverse proxyOliver Giles-0/+1
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-04-06resolves #34: watch for configuration changesOliver Giles-12/+29
Reload the configuration if a change is detected without requiring a server restart
2018-04-06laminarc: replace start with runOliver Giles-2/+2
2018-04-06resolves #33: laminar start output should reference run numberOliver Giles-1/+3
2018-02-24resolves #29: graceful shutdownOliver Giles-26/+56
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-01-27resolves #31: exception thrown on bad file descriptorOliver Giles-19/+36
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
2017-12-29webui may be modified with custom style.cssOliver Giles-0/+4
2017-12-21fix pedantic compiler warningsOliver Giles-10/+8
2017-12-16server: minor websocket client handler refactorOliver Giles-39/+18
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-09Fix copyright yearsOliver Giles-1/+1
This reverts commit 4e911756bcca87111b3285aadc808dee3c32ec63. In addition, copyright years are now expressed in the form of (year file added)-(year file last changed)
2017-12-07server: use regular char array as bufferOliver Giles-6/+6
This approach finally solves the crash under hardened gentoo discussed in #19
2017-12-06remove unnecessary attach()Oliver Giles-1/+1
2017-12-06server: allocate a single buffer per file descriptorOliver Giles-6/+6
2017-12-06attempt to solve segfault under hardened gentooOliver Giles-3/+2
Can't reproduce this locally, but looks like using a std::string as an arbitrary buffer is causing problems. See #19
2017-12-04don't leak file descriptors into runsOliver Giles-1/+1
2017-12-04resolves #19: laminard crashes under loadOliver Giles-6/+7
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-10-31send correct Content-Type header for static resourcesOliver Giles-2/+3
2017-08-15unlink unix sockets before bindingOliver Giles-0/+4