Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • oss/utilities/conan
1 result
Show changes
Commits on Source (2)
Showing
with 240 additions and 33 deletions
...@@ -41,7 +41,7 @@ include $(MAKEFILE_IMPORT_PATH)directories-standard.mk ...@@ -41,7 +41,7 @@ include $(MAKEFILE_IMPORT_PATH)directories-standard.mk
#include $(MAKEFILE_IMPORT_PATH)jsdoc.mk #include $(MAKEFILE_IMPORT_PATH)jsdoc.mk
include $(MAKEFILE_IMPORT_PATH)output.mk include $(MAKEFILE_IMPORT_PATH)output.mk
include $(MAKEFILE_IMPORT_PATH)placeholder.mk include $(MAKEFILE_IMPORT_PATH)placeholder.mk
#include $(MAKEFILE_IMPORT_PATH)s3.mk include $(MAKEFILE_IMPORT_PATH)s3.mk
#include $(MAKEFILE_IMPORT_PATH)license-agpl3.mk #include $(MAKEFILE_IMPORT_PATH)license-agpl3.mk
#include $(MAKEFILE_IMPORT_PATH)jsdoc-json.mk #include $(MAKEFILE_IMPORT_PATH)jsdoc-json.mk
include $(MAKEFILE_IMPORT_PATH)go.mk include $(MAKEFILE_IMPORT_PATH)go.mk
......
# A small, self-contained, cross-platform web server for development
This tool helps to serve files.
## Install
Conan is a binary file that must be stored in a directory.
The files can be found [here](http://download.schukai.com/tools/conan/).
```bash
wget -O ~/.local/bin/conan http://download.schukai.com/tools/conan/conan-linux-amd64
## For Linux, the execution bit must still be set.
chmod u+x ~/.local/bin/conan
```
## Commands
### General Parameters
#### Configuration
```yaml
Server:
# The hostname or IP address of the server (CONAN_SERVER_HOST)
# Domain, IP or hostname of the server
# Host: localhost:8080
# The port of the server (CONAN_SERVER_ADDRESS)
# Address: localhost
# The port of the server (CONAN_SERVER_PORT)
# Port: 8080
#
Path:
# The path to the server (CONAN_SERVER_WEB_PATH)
Web: web
Watch:
- Path: src
Command: /bin/bash -c "npx esbuild --bundle --outfile={{ .WebPath }}/scripts/bundle.js --sourcemap {{ .Path }}"
Exclude:
- ~$
- ^\.
- Path: web
Exclude:
- ~$
- ^\.
Flags:
FollowSymlinks: true
```
### Server
Start server and deliver files.
```bash
conan server serve
```
Start with configuration file.
```bash
conan server start --config config.yaml
```
### Help
There is help on the command line for each individual command.
```bash
conan --help
```
## Change Log
- Version 1.0
- Initial release
## License # Credits
- Icons Font Face - https://fontawesome.com/
- Bootstrap 5 - http://getbootstrap.com/
package command package command
import ( import (
"fmt"
"gitlab.schukai.com/oss/utilities/conan/configuration" "gitlab.schukai.com/oss/utilities/conan/configuration"
"gitlab.schukai.com/oss/utilities/conan/logging" "gitlab.schukai.com/oss/utilities/conan/logging"
"gitlab.schukai.com/oss/utilities/conan/server" "gitlab.schukai.com/oss/utilities/conan/server"
"os"
"path"
) )
type ServerServeCommand struct { type ServerServeCommand struct {
Port string `long:"port" short:"p" description:"Port to listen on"` Port string `long:"port" short:"p" description:"Port to listen on"`
Address string `long:"address" short:"a" description:"Address to serve on"` Address string `long:"address" short:"a" description:"Address to serve on"`
WebPath string `long:"web-path" short:"e" description:"Path to web files"` WebPath string `long:"web-path" short:"e" description:"Path to web files"`
WatchPath string `long:"watch-path" short:"w" description:"Path to watch for changes"` WatchPath string `long:"watch-path" short:"w" description:"Path to watch for changes"`
Exclude string `long:"exclude" short:"x" description:"Exclude pattern"` Exclude []string `long:"exclude" short:"x" description:"Exclude pattern"`
} }
func (r *ServerServeCommand) execute() { func (r *ServerServeCommand) execute() {
logging.InitLogger()
configuration.SetServerPort(r.Port) configuration.SetServerPort(r.Port)
configuration.SetServerAddress(r.Address) configuration.SetServerAddress(r.Address)
configuration.SetServerWebPath(r.WebPath) configuration.SetServerWebPath(r.WebPath)
fmt.Printf("Serving on %s:%s\n", r.WatchPath, r.Exclude)
var w string
if r.WatchPath != "" { if r.WatchPath != "" {
w = r.WatchPath
if !path.IsAbs(w) {
wd, err := os.Getwd()
if err != nil {
logging.LogError("ServerServeCommand error %s", err.Error())
return
}
w = path.Join(wd, w)
}
configuration.AddWatch(configuration.Watch{ configuration.AddWatch(configuration.Watch{
Path: r.WatchPath, Path: w,
Exclude: []string{ Exclude: r.Exclude,
r.Exclude,
},
}) })
} }
logging.InitLogger()
server.Start() server.Start()
} }
...@@ -25,7 +25,7 @@ func injectHandler(next http.Handler) http.Handler { ...@@ -25,7 +25,7 @@ func injectHandler(next http.Handler) http.Handler {
p, err := os.ReadFile(path) p, err := os.ReadFile(path)
if err != nil { if err != nil {
logging.LogError("injectHandler error %s", err.Error()) logging.LogError("InjectHandler error %s", err.Error())
return return
} }
...@@ -54,6 +54,7 @@ func init() { ...@@ -54,6 +54,7 @@ func init() {
<script type="module"> <script type="module">
try { try {
let died = false;
let counter = 0; let counter = 0;
let socket let socket
let url = "" let url = ""
...@@ -79,6 +80,11 @@ func init() { ...@@ -79,6 +80,11 @@ func init() {
socket = new WebSocket(url) socket = new WebSocket(url)
socket.onopen = function (e) { socket.onopen = function (e) {
if (died===true ){
window.location.reload();
}
console.log("[conan] Connection established"); console.log("[conan] Connection established");
counter = 0 counter = 0
}; };
...@@ -97,12 +103,13 @@ func init() { ...@@ -97,12 +103,13 @@ func init() {
console.log("[conan] Connection closed cleanly, code=" + event?.code + " reason=" + event?.reason + ""); console.log("[conan] Connection closed cleanly, code=" + event?.code + " reason=" + event?.reason + "");
} else { } else {
console.error("[conan] Connection died"); console.error("[conan] Connection died");
died = true
setTimeout(connectWebsocket, 3000*counter) setTimeout(connectWebsocket, 3000*counter)
} }
}; };
socket.onerror = function (error) { socket.onerror = function (error) {
console.error("[conan] " + error?.message); console.error("[conan] error", error);
}; };
} }
......
...@@ -116,8 +116,6 @@ func executeWatchAction(watchPath string) { ...@@ -116,8 +116,6 @@ func executeWatchAction(watchPath string) {
r, err := result.String() r, err := result.String()
logging.LogDebug("%s", r) logging.LogDebug("%s", r)
websocket.SendReloadMessage()
if err != nil { if err != nil {
logging.LogError("watching: execute watch action error: %v", err.Error()) logging.LogError("watching: execute watch action error: %v", err.Error())
continue continue
...@@ -201,9 +199,13 @@ func InitWatch() { ...@@ -201,9 +199,13 @@ func InitWatch() {
}) })
} }
watchList = append(watchList, configuration.Watch{ c := path.Join(configuration.GetConfigurationPath(), constants.ConfigFileName)
Path: path.Join(configuration.GetConfigurationPath(), constants.ConfigFileName),
}) if _, err := os.Stat(c); err == nil {
watchList = append(watchList, configuration.Watch{
Path: path.Join(configuration.GetConfigurationPath(), constants.ConfigFileName),
})
}
for _, w := range watchList { for _, w := range watchList {
scanPath(w.Path) scanPath(w.Path)
......
...@@ -6,6 +6,8 @@ import ( ...@@ -6,6 +6,8 @@ import (
"gitlab.schukai.com/oss/utilities/conan/logging" "gitlab.schukai.com/oss/utilities/conan/logging"
"log" "log"
"net/http" "net/http"
"sync"
"time"
) )
var ( var (
...@@ -14,7 +16,7 @@ var ( ...@@ -14,7 +16,7 @@ var (
) )
func SendMessageToAll(message []byte) { func SendMessageToAll(message []byte) {
logging.LogInfo("sending message to all")
for _, conn := range connections { for _, conn := range connections {
conn.WriteMessage(websocket.TextMessage, message) conn.WriteMessage(websocket.TextMessage, message)
} }
...@@ -30,8 +32,35 @@ func closeConnection(session string) error { ...@@ -30,8 +32,35 @@ func closeConnection(session string) error {
return nil return nil
} }
func SendReloadMessage() { var timerMutex *sync.Mutex
var waitForReload bool
func init() {
timerMutex = &sync.Mutex{}
waitForReload = false
}
func doReload() {
timerMutex.Lock()
defer timerMutex.Unlock()
SendMessageToAll([]byte("reload")) SendMessageToAll([]byte("reload"))
waitForReload = false
}
func SendReloadMessage() {
timerMutex.Lock()
defer timerMutex.Unlock()
if waitForReload {
return
}
time.AfterFunc(time.Second, doReload)
logging.LogInfo("timer ...")
waitForReload = true
} }
func GetWebsocketHandler() http.Handler { func GetWebsocketHandler() http.Handler {
...@@ -49,7 +78,6 @@ func GetWebsocketHandler() http.Handler { ...@@ -49,7 +78,6 @@ func GetWebsocketHandler() http.Handler {
conn.SetCloseHandler(func(code int, text string) error { conn.SetCloseHandler(func(code int, text string) error {
return closeConnection(session) return closeConnection(session)
}) })
connections[session] = conn connections[session] = conn
......
This diff is collapsed.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="index.css" rel="stylesheet">
<style>
body {
background-color: #ffffff;
}
</style>
<title>Download Portal schukai GmbH</title>
</head>
<body>
<div class="d-flex flex-column align-items-center justify-content-center"
style="height:100vh;">
<div class="text-center">
<a href="https://www.schukai.com" class="text-decoration-none text-white text-decoration"><img
src="https://cdn.alvine.io/image/logo/schukai-rot.svg" width="300px"></a>
<br>
<div class="card mt-5">
<div class="card-header">
Conan
</div>
<ul class="list-group">
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-386">conan-linux-386</a>
</li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-amd64">conan-linux-amd64</a>
</li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-arm">conan-linux-arm</a>
</li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-linux-arm64">conan-linux-arm64</a>
</li>
<li class="list-group-item"><a class="text-decoration-none link-danger" href="./conan-windows">conan-windows</a>
</li>
</ul>
</div>
<p class="mt-5">
<a href="https://about.schukai.com/de/impressum/" class="text-decoration-none text-decoration"
style="color:#c10000">Imprint</a></p>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
This diff is collapsed.
...@@ -18,7 +18,7 @@ Server: ...@@ -18,7 +18,7 @@ Server:
Watch: Watch:
- Path: src - Path: src
Command: /bin/bash -c "PATH=$PATH:/home/volker.schukai/.nvm/versions/node/v18.8.0/bin; npx esbuild --bundle --outfile={{ .WebPath }}/scripts/bundle.js --sourcemap {{ .Path }}" Command: /bin/bash -c "npx esbuild --bundle --outfile={{ .WebPath }}/scripts/bundle.js --sourcemap {{ .Path }}"
Exclude: Exclude:
- ~$ - ~$
- ^\. - ^\.
......
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#app").innerHTML = "Hello!!! World?!"; let text="how are you doing?"
document.querySelector("#app").innerHTML = text;
}) })
// Language: javascript // Language: javascript
\ No newline at end of file
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
<script src="scripts/bundle.js"></script> <script src="scripts/bundle.js"></script>
</head> </head>
<body> <body>
<h1>Hello ...ddd</h1> <h1>Hello Developer!?</h1>
<div id="app"></div>
<div id="app"></div>
</body> </body>
(() => { (() => {
// src/main.js // src/main.js
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#app").innerHTML = "Hello!!! World?!"; let text = "how are you doing?";
document.querySelector("#app").innerHTML = text;
}); });
})(); })();
//# sourceMappingURL=bundle.js.map //# sourceMappingURL=bundle.js.map
{ {
"version": 3, "version": 3,
"sources": ["../../src/main.js"], "sources": ["../../src/main.js"],
"sourcesContent": ["document.addEventListener(\"DOMContentLoaded\", () => {\n document.querySelector(\"#app\").innerHTML = \"Hello!!! World?!\";\n})\n// Language: javascript "], "sourcesContent": ["document.addEventListener(\"DOMContentLoaded\", () => {\n let text=\"how are you doing?\"\n document.querySelector(\"#app\").innerHTML = text;\n})\n// Language: javascript \n"],
"mappings": ";;AAAA,WAAS,iBAAiB,oBAAoB,MAAM;AAChD,aAAS,cAAc,MAAM,EAAE,YAAY;AAAA,EAC/C,CAAC;", "mappings": ";;AAAA,WAAS,iBAAiB,oBAAoB,MAAM;AAChD,QAAI,OAAK;AACT,aAAS,cAAc,MAAM,EAAE,YAAY;AAAA,EAC/C,CAAC;",
"names": [] "names": []
} }
...@@ -17,4 +17,6 @@ deploy: compile ...@@ -17,4 +17,6 @@ deploy: compile
.PHONY: overview-to-s3 .PHONY: overview-to-s3
## overview-to-s3 ## overview-to-s3
overview-to-s3: overview-to-s3:
$(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.html $(UPLOAD_TOOL_URL) $(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.html $(UPLOAD_TOOL_URL)
\ No newline at end of file $(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.css $(UPLOAD_TOOL_URL)
$(QUIET) AWS_PROFILE=$(AWS_PROFILE) $(AWS) s3 cp $(WEB_PATH)/index.js $(UPLOAD_TOOL_URL)
\ No newline at end of file
{"version":"0.1.19"} {"version":"0.1.36"}