https://github.com/damesek/golang-clojurescript
Gracefully shutdown server with Golang for exported Clojurescript projects
https://github.com/damesek/golang-clojurescript
cljs clojure clojurescript golang shadow-cljs
Last synced: 3 months ago
JSON representation
Gracefully shutdown server with Golang for exported Clojurescript projects
- Host: GitHub
- URL: https://github.com/damesek/golang-clojurescript
- Owner: damesek
- Created: 2020-09-16T09:35:08.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-03T17:29:25.000Z (over 4 years ago)
- Last Synced: 2023-09-12T10:42:14.837Z (almost 2 years ago)
- Topics: cljs, clojure, clojurescript, golang, shadow-cljs
- Language: Go
- Homepage: https://github.com/damesek/golang-clojurescript
- Size: 18.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gracefully shutdown Clojurescript with fast Go backend
TODO add fasthttp packageIn this way x5 better performance (with fasthttp x10) vs non-clustered nodejs.
I used a *shadow-cljs project example* [https://github.com/shadow-cljs/quickstart-browser] and a *gracefull shutdown Go example* to create that mix.Clone the repo or just Release RELEASE_X86_64 file and run
*I use Mac OSX x86_64, if you use Linux/Windows/RPI maybe better if you rebuild*
```bash
./gocljs
```
-> Don't forget add your public folder with index.html or unzip [public.zip] my shadow-cljs test
After this you can see the message:
```bash
2021/03/03 18:10:11 server started
```
on localhost:8081When you stop the server with CTRC+C, you will see:
```bash
^C2021/03/03 18:11:32 system call:interrupt
2021/03/03 18:11:32 server stopped
2021/03/03 18:11:32 server exited properly
```Details:
Test with
```shell
go run gocljs.go
```
or compile a file to architecture
```shell
go build .
```
We use external files in this example, but I tested without any problem possible compile into binary the css/js/html files or run CLJS with V8 engine from Golang.Links more info:
- https://medium.com/@pinkudebnath/graceful-shutdown-of-golang-servers-using-context-and-os-signals-cc1fa2c55e97. That is possible with js/process `(.on js/process "SIGINT" shutdown-gracefully-functions)` and
- Clojure side too (https://medium.com/helpshift-engineering/achieving-graceful-restarts-of-clojure-services-b3a3b9c1d60d).Btw "Go- and Java-based webservers have shown to be the most efficient. Clustered NodeJS is reasonably efficient, but will run out of RAM once overloaded." Source: https://stressgrid.com/blog/webserver_benchmark/