Commit 2d3f5d14 authored by Camil Staps's avatar Camil Staps 🚀

Added backend/ and frontend/; reorganisation; some cleanup

parent 5ad4f849
Clean System Files/
search
builddb
CloogleServer
*.prj
*.1
types.db
types.json
cloogle.log
node_modules/
[submodule "CleanTypeUnifier"]
path = CleanTypeUnifier
path = backend/CleanTypeUnifier
url = https://github.com/camilstaps/CleanTypeUnifier
[submodule "CleanLevenshtein"]
path = CleanLevenshtein
path = backend/CleanLevenshtein
url = https://github.com/camilstaps/CleanLevenshtein
......@@ -39,29 +39,36 @@ frontends:
### Backend
- Add `env/envs.linux64` to your `$CLEAN_HOME/etc/IDEEnvs`.
```bash
$ cd backend
$ cat env/envs.linux64 >> "$CLEAN_HOME/etc/IDEEnvs"
$ make
```
- Run `make`. This builds all necessary binaries and runs `builddb`, which
creates a file `types.db` which holds the internal database of functions and
their types. If you add new libraries later on, you need to rerun `builddb`.
You have now built the necessary binaries and created `types.db`, which holds
the internal database.
- You can then run the Clean backend with:
You can now run the CloogleServer with:
$ ./CloogleServer 31215 < types.db
```bash
$ ./CloogleServer 31215 < types.db
```
Alternatively, use `serve` as a wrapper. It will restart the server on
crashes, and log to both stdout and cloogle.log:
Alternatively, use `serve` as a wrapper. It will restart the server on
crashes, and log to both stdout and cloogle.log:
$ ./serve
```bash
$ ./serve
```
In this example, the server uses port 31215. You need to use the same
settings in `api.php`.
In this example, the server uses port 31215. You need to use the same settings
in `frontend/api.php`.
Leave the `CloogleServer` running.
Leave the `CloogleServer` running.
- Install a web server with PHP support to handle requests for `api.php`. When
an HTTP request for `api.php` is made, that PHP script will communicate with
the Clean backend server.
Install a web server with PHP support to handle requests for the `frontend`
directory. When an HTTP request for `api.php` is made, that PHP script will
communicate with the Clean backend server.
### Live statistics
The live version's statistics page is at
......@@ -71,12 +78,16 @@ There is a possibility to set up a web page that shows live statistics.
Currently, only the last few searches are shown. For this, you need to have
`nodejs` installed. Then do:
$ cd stats
$ npm install
```bash
$ cd frontend/stats
$ npm install
```
And to run:
$ node server.js ../cloogle.log
```bash
$ node server.js ../../backend/cloogle.log
```
This starts a WebSocket server on port 31216. You can navigate to `/stats` to
view the statistics. This page will receive live updates.
......@@ -91,21 +102,27 @@ forwarding rules.
### Cloogle server
$ docker build -t cloogle .
$ docker run -d --net=host --name=cloogle \
-v "$PWD/cloogle.log":/usr/src/cloogle/cloogle.log \
cloogle
$ docker start cloogle
```bash
$ cd backend
$ sudo touch /var/log/cloogle.log
$ docker build -t cloogle .
$ docker run -d --net=host --name=cloogle \
-v /var/log/cloogle.log:/usr/src/cloogle/cloogle.log \
cloogle
$ docker start cloogle
```
### Live statistics
$ cd stats
$ docker build -t cloogle-stats .
$ docker run -d --net=host --name=cloogle-stats \
-v "$PWD/../cloogle.log":/var/www/cloogle.log \
cloogle-stats \
/var/www/cloogle.log
$ docker start cloogle-stats
```bash
$ cd frontend/stats
$ docker build -t cloogle-stats .
$ docker run -d --net=host --name=cloogle-stats \
-v /var/log/cloogle.log:/var/log/cloogle.log \
cloogle-stats \
/var/log/cloogle.log
$ docker start cloogle-stats
```
## HTTP API specification
`api.php` should be called with a `GET` request where the `str` variable
......
File moved
File moved
BIN:=CloogleServer builddb
PRJ:=$(addsuffix .prj,$(BIN))
DB=types.db
DB=types.json
MAN:=builddb.1 # Others don't have --help/--version # $(addsuffix .1,$(BIN))
CPM:=cpm
SED:=sed
......
......@@ -12,7 +12,7 @@ instance zero (Logger a b s) where zero = \_ _ w -> (undef, w)
serve :: (a *World -> *(b,*World)) (Maybe (Logger a b s)) Port *World -> *World | fromString a & toString b
serve f log port w
# (ok, mbListener, w) = openTCP_Listener port w
| not ok = abort ("Couldn't open port " +++ toString port)
| not ok = abort ("Couldn't open port " +++ toString port +++ "\n")
# listener = fromJust mbListener
# log = if (isNothing log) zero (fromJust log)
# (_,w) = signal 17 1 w // SIGCHLD, SIG_IGN: no notification if child ps dies
......
......@@ -76,7 +76,7 @@ instance zero CLI where
VERSION :== "Cloogle's builddb version 0.1\n"
USAGE :== concat [
VERSION, "\n",
"Usage: ./builddb [opts] > builddb.json\n\n",
"Usage: ./builddb [opts] > types.json\n\n",
"\t-h, --help Show this help\n",
"\t-r PATH Change the library root to PATH\n",
"\t-l PATH Add PATH to the librarypaths relative to the root\n"]
......
#!/bin/sh
while :
do
< types.db \
< types.json \
stdbuf -i0 -o0 -e0 \
./CloogleServer 31215 \
| tee -a cloogle.log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment