Commit Graph

78 Commits

Author SHA1 Message Date
Joris Vink 8aaf7aaf79 Alter where the version number comes from.
Now if we are a git repo we fetch the branch name and
commitid to build the version string. If there is no
git repo we'll look at the RELEASE file.
2018-06-22 14:24:42 +02:00
Joris Vink 7b20192e02 install kodev manual page. 2018-06-19 22:40:55 +02:00
Joris Vink c257299fa4 add shorthand for building with fsanitize. 2018-06-12 19:43:10 +02:00
Joris Vink 4cfdda290f install headers correct again 2018-03-30 13:47:12 +02:00
Joris Vink e6833a4892 Move header files to include/kore.
Mimics how the header files are installed on a system
as PREFIX/include/kore.

This is required for getting kodev to use the headers from the
kore_source option instead of requiring the kore headers to be
installed on the system even when building as a single_binary.
2018-03-30 13:45:29 +02:00
Joris Vink dd2dff2318 Rework HTTP and worker processes.
The HTTP layer used to make a copy of each incoming header and its
value for a request. Stop doing that and make HTTP headers zero-copy
all across the board.

This change comes with some api function changes, notably the
http_request_header() function which now takes a const char ** rather
than a char ** out pointer.

This commit also constifies several members of http_request, beware.

Additional rework how the worker processes deal with the accept lock.

Before:
	if a worker held the accept lock and it accepted a new connection
	it would release the lock for others and back off for 500ms before
	attempting to grab the lock again.

	This approach worked but under high load this starts becoming obvious.

Now:
	- workers not holding the accept lock and not having any connections
	  will wait less long before returning from kore_platform_event_wait().

	- workers not holding the accept lock will no longer blindly wait
	  an arbitrary amount in kore_platform_event_wait() but will look
	  at how long until the next lock grab is and base their timeout
	  on that.

	- if a worker its next_lock timeout is up and failed to grab the
	  lock it will try again in half the time again.

	- the worker process holding the lock will when releasing the lock
	  double check if it still has space for newer connections, if it does
	  it will keep the lock until it is full. This prevents the lock from
	  bouncing between several non busy worker processes all the time.

Additional fixes:

- Reduce the number of times we check the timeout list, only do it twice
  per second rather then every event tick.
- Fix solo worker count for TLS (we actually hold two processes, not one).
- Make sure we don't accidentally miscalculate the idle time causing new
  connections under heavy load to instantly drop.
- Swap from gettimeofday() to clock_gettime() now that MacOS caught up.
2018-02-14 13:48:49 +01:00
Joris Vink 03d5e4852b make sure FEATURES_INC hits kore.features. 2017-08-30 12:03:58 +02:00
Joris Vink fc6b3bf740 Split up kore cli tools into new binary.
Having the create, build, run tools baked into the kore binary
made things harder then they had to be for multiple projects with
each different build flavors.

So move away this functionality into a new "kodev" (name may change)
binary that is installed next to kore.

The new build tools will automatically pick up the correct flavors
the kore binary it points to is installed with. Or for single builds
what flavors where enabled.

The new tool also will honor looking into PREFIX for the kore binary
when doing a `kodev run`.

Additionally add a new command "info" that shows some basic info
about your project and how it will be built. For example it will
show you the flavors of the kore binary installed on the system
or the flavors you configured for a single binary build.

Obligitory, hacking on a plane comment.
2017-02-19 00:52:29 -05:00
Joris Vink e895446dfa Improve single binary builds.
Allow kore build to pickup the required libraries for kore when
building single binaries so that you no longer have to manually
add them to ldflags.
2017-02-09 11:30:44 +01:00
Joris Vink bbcdec82fc Add initial python support.
Based on work done by Stanislav Yudin.
2017-01-24 20:18:12 +01:00
Joris Vink 77adb35193 JSONRPC requires HTTP, let users figure that out the hard way. 2016-08-01 09:25:56 +02:00
Joris Vink 46cee2ff46 Typo. 2016-07-15 22:34:21 +02:00
Joris Vink f5923af1c6 Add /usr/local/[include|lib] for BSD / JSONRPC. 2016-07-15 22:33:58 +02:00
Raphaël Monrouzeau cd9ce057ea JSONRPC Changed Makefile option location 2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau db02e990ea JSON-RPC support for Kore.
The API surface is very limited. Jsonrpc support reads request from HTTP
body and such can't be activated if NOHTTP=1. At the moment there is no
websocket support either (which is a shame). It depends upon the
third-party Yajl library.

Errors can be emitted using jsonrpc_error() and results using
jsonrpc_result(), for the later you'll have to provide a callback which
will write the inner of the result object.

If errors happen during the response write process, no further error
output will be attempted and an HTTP error 500 will be returned.

Read the provided example for getting a better idea of the API.
2016-07-15 13:08:08 +02:00
Joris Vink 39a5f21986 Allow "kore build" to produce single binaries.
Producing single binaries can now be done with building with
"kore build". To get started edit your build.conf and add the
following directives:

single_binary = yes
kore_source = /path/to/kore

optionally you can add kore_flavor to instruct how kore should
be built:

kore_flavor = NOTLS=1

When doing this your build.conf must also include the correct
linking options as the linking is now done fully by kore build.

The binary produced will include your configuration and takes
over a few of kore its command line flags (such as -f, -n or -r).
2016-07-06 16:16:15 +02:00
Joris Vink ae31ec01ac Separate private keys from worker processes.
Kore will now isolate RSA private keys to a separate process (keymgr).

Worker processes that require RSA signing for TLS connections will
communicate with this keymgr process in order to do so.

This behaviour cannot be disabled and is always turned on.
2016-06-08 13:56:38 +02:00
Joris Vink 090e2cc6a2 Debug builds imply NOOPT 2016-02-13 14:21:09 +01:00
Joris Vink 1f5e482b8a Build option changes.
- Build with -O2 unless NOOPT is set to 1.
- Hide -g behind DEBUG instead of always building with it.
- Explicitely set the standard used to c99, use pedantic.
2016-02-01 15:33:40 +01:00
Joris Vink b4611ee38d Kill off zlib_dict.c 2015-12-04 14:11:37 +01:00
Joris Vink 769c78a6e8 Introduce NOHTTP=1 build option.
This basically turns off the HTTP layer for Kore. It does not
compile in anything for HTTP.

This allows Kore to be used as a network application platform as well.
Added an example for this called nohttp.

Other changes that sneaked in while hacking on this:
* Use calloc(), kill pendantic malloc option.
* Killed off SPDY/3.1 support completely, will be superseded by http2

Note that comes with massive changes to a lot of the core API
functions provided by Kore, these might break your application.
2015-11-27 16:22:50 +01:00
Nandor Kracser 3633270de3 Don't link object files if not needed 2015-07-25 19:10:48 +02:00
Joris Vink 49ca95f390 Add our messaging framework.
With this framework apps can now send messages between worker processes.

A new API function exists:
	int kore_msg_register(u_int8_t id, void (*cb)(const void *, u_int32_t);

This API call allows your app to register a new message callback for a given ID.

You can then send messages on this ID to other workers using:
	void kore_msg_send(u_int8_t id, void *data, u_int32_t length);

This framework will interally be used for a few things such as allowing
websocket data to broadcasted between all workers, adding unified caching
and hopefully eventually moving the access log to this as well.

Some internals have changed with this commit:
	* worker_clients has been called connections.
	* the parent now initializes the net, and event subsystems.
	* kore_worker_websocket_broadcast() is dead.
2015-06-22 21:13:32 +02:00
Geenz 817b916e1f Call it NOTLS instead.
Per @jorisvink's feedback.
2015-05-25 09:42:34 -04:00
Geenz c44de3f629 Rename BENCHMARK to reflect its actual function.
NO_SSL makes a bit more sense, especially for people who proxy their requests via nginx, apache, or similar.
2015-05-25 09:28:13 -04:00
Joris Vink 2ee09b6a43 Kill lingering PHONY target. 2015-05-21 14:59:56 +02:00
Thordur Bjornsson abacc14a2c top level dockerfile not generally useful.
So, garbage collect.
2015-05-21 14:42:25 +02:00
Thordur Bjornsson 9c2e902b81 Contain the kore.
Add a top level Dockerfile, not really useful for anything besides
hacking on kore. See `make contain`;

Add docker top level directory, it contains an `app` container,
with a `kore run` ENTRYPOINT, an example of using that image is

   FROM kore/app

   COPY . myapp
   CMD ["myapp"]

There is also a `build` image, which is the base for both aforementioned
containers.
2015-05-20 16:31:28 +02:00
Joris Vink d6ab1d7445 Add rudimentary timers to Kore.
Timers are in ms resolution and are added using
kore_timer_add(cb, interval, flags).

Both oneshot timers and continious timers are supported.
2015-04-06 18:54:35 +02:00
Andreas Pfohl 24e1d3928d Added ability to set path prefix during make. 2014-12-12 10:15:30 +01:00
Joris Vink 8fe16c193a Link with -lcrypto even for BENCHMARK 2014-11-24 11:31:50 +01:00
Joris Vink f867882f43 Add websocket support to Kore.
Introduces a few new api functions:

- kore_websocket_handshake(struct http_request *):
	Performs the handshake on an HTTP request (coming from page handler)

- kore_websocket_send(struct connection *, u_int8_t, void *, size_t):
	Sends data to a websocket connection.

- kore_websocket_broadcast(struct connection *, u_int8_t, void *, size_t, int):
	Broadcast the given websocket op and data to all connected
	websocket clients on the worker. Note that as of right now
	the WEBSOCKET_BROADCAST_GLOBAL scope option does not work
	yet and messages broadcasted will be restricted to workers
	only.

- kore_worker_websocket_broadcast(struct connection *, void *, void *):
	Backend function used by kore_websocket_broadcast().
	Could prove useful for developers to have access to.

A simple example is given under examples/websocket.

Known issues:
	Kore does not support PING or CONT frames just yet.
2014-11-24 11:08:34 +01:00
Thordur Bjornsson c271ea6b3e Honor CC from the environment. 2014-10-22 17:02:25 +02:00
Joris Vink b668125ff7 Allow kore to build with openssl from osx brew. 2014-10-13 11:53:56 +02:00
Joris Vink 2b40672ba1 When compiling with PGSQL, note the include dir for "kore build" 2014-08-03 17:33:40 +02:00
Joris Vink c078c8a306 Correct order for linking 2014-08-02 13:01:58 +02:00
Joris Vink ea5b89d20b Move orbit functionality into kore directly.
Makes more sense and reads easier:

kore create myapp
kore build myapp
kore run myapp

Note that kore retains its cli options (if no command was given),
meaning you can still start kore in the traditional way as well.

The command options are simply to make development easier.
2014-08-01 13:59:47 +02:00
Joris Vink 0c21c08b6d Hook orbit into the build 2014-08-01 10:46:50 +02:00
Joris Vink c2e4d55235 Add a BENCHMARK compile option which compiles without OpenSSL.
Personally use this for testing Kore its performance without
letting the OpenSSL stack get in the way too much.

Note that it leaves data structures as is, and just removes
any calls to OpenSSL (and removes the linking vs OpenSSL).
2014-08-01 10:22:32 +02:00
Joris Vink b6a778a4a5 Install kore headers under /usr/local/include/kore 2014-07-03 22:39:16 +02:00
Joris Vink 4f126f51d3 Add install/uninstall targets. 2014-07-03 21:38:16 +02:00
Joris Vink be4b1c7e7b Move actual code out of contrib into src/. 2014-07-02 12:19:38 +02:00
Joris Vink cf700b34f7 Add initial stab at asynchronous background tasks.
More to follow.
2014-06-28 16:17:18 +02:00
Joris Vink d98d56fb20 Add KORE_PENDANTIC_MALLOC option.
This option tells Kore to zero out memory when allocated, freed or
when get/put from the pools.
2014-04-22 12:46:23 +02:00
Joris Vink 89b603c247 Support postgresl under the bsds 2014-04-02 00:06:24 +02:00
Joris Vink 22882261f7 Properly use pg_config --includedirs + move modules to contrib 2014-03-31 11:29:51 +02:00
Joris Vink 2f044cc7eb Initial stab at entering postgresql contrib code.
Has support for full async pgsql queries. Most of the logic
is hidden behind a KORE_PGSQL() macro allowing you to insert
these pgsql calls in your page handlers without blocking the
kore worker while the query is going off.

There is place for improvement here, and perhaps KORE_PGSQL won't
stay as I feel this might overcomplicate things instead of making
them simpler as I thought it would.
2014-03-30 23:54:35 +02:00
Joris Vink 9a8092bf41 Add authentication blocks for Kore.
Using authentication blocks one can define "authentication" mechanisms
in Kore for page handlers.

This can be used to require a session cookie (validated by your own validator)
for certain page handlers, and hopefully in the future provide a framework
for adding more authentication things (like HTTP Auth).

Right now only cookie checking is available.
2014-01-22 22:55:10 +01:00
Joris Vink b647afcc4f fix brocken DEBUG define 2013-11-21 12:00:07 +01:00
Thordur Bjornsson 302c3b6c9d If DEBUG is set in the environment, define KORE_DEBUG 2013-11-19 13:10:01 +01:00