commit 9c99aa375bab8c89027d8faf1500e43202fed2be Author: Christopher Baines Date: Wed Jul 16 14:23:04 2025 +0100 Initial commit diff --git a/ENTRY b/ENTRY new file mode 100644 index 0000000..8e39f7a --- /dev/null +++ b/ENTRY @@ -0,0 +1,45 @@ +;; This an Artanis ENTRY file, don't remove it! + + (use-modules (artanis artanis) + ;; Put modules you want to be imported here + ;; only for this file, not controllers/views + + (artanis utils)) + +(use-modules (srfi srfi-71) + (artanis artanis) + (web uri) + (web client) + (web request)) + + + + ;; Put whatever you want to be called before server initilization here + + (init-server #:statics '(png gif jpg jpeg ico html js json csv xml css woff woff2 ttf)) + (add-to-load-path (string-append (current-toplevel) "/lib")) + ;; Put whatever you want to be called before server running here + +(get "/" + (lambda () + (let* ((uri + (string->uri + (string-append + ;; No HTTPS because Guile/Guile GnuTLS doesn't + ;; support TLS handshakes on a non blocking socket + ;; yet + "http://data.guix.gnu.org" + "/revision/e5478c6acf74c3d5b1d25125baac23171403bd1d" + "/packages.json?locale=en_US.UTF-8&field=version&field=synopsis&limit_results=100"))) + (socket + (open-socket-for-uri uri))) + + ;; If you comment out the following line, this example will work + (fcntl socket F_SETFL (logior O_NONBLOCK (fcntl socket F_GETFL))) + + (let ((response + body + (http-get uri + #:port socket + #:streaming? #t))) + (simple-format #f "~A" (json->scm body)))))) diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/app/.gitkeep b/app/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/protocols/.gitkeep b/app/protocols/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/.gitkeep b/app/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/conf/.gitkeep b/conf/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/conf/artanis.conf b/conf/artanis.conf new file mode 100644 index 0000000..9059877 --- /dev/null +++ b/conf/artanis.conf @@ -0,0 +1,325 @@ +## -*- indent-tabs-mode:nil; coding: utf-8 -*- +## Copyright (C) 2025 +## "Mu Lei" known as "NalaGinrut" +## Artanis is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. + +## Artanis is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . + +## --------------------------------------------------------------------- +## The skeleton of config file, you may modify it on your own purpose. +## DON'T TYPE `;' AT THE END OF LINE!!! +## --------------------------------------------------------------------- + +## Please read the manual or /etc/artanis/default.conf if you have problem +## to understand these items. + + +## Whether to use a database, if disabled, the database won't be initialized +## in the beginning, which saves memory and boot time. +## Some users may want to use GNU Artanis without configuring any databases, if +## that's your case please set it to `false' to avoid unintended errors. +## db.enable = +db.enable = false + +## What database server should be used, depends on the database installed +## on your machine. +## NOTE: If you use MariaDB then you should set it to mysql. +## db.dbd = mysql | postgresql | sqlite3 +db.dbd = mysql + +## The protocol for connecting the databse. If you use tcp, a socket port +## must be specified in the address. And if you choose socketfile, then you should +## specify the unix socket file managed by database server. +## db.proto = tcp | socketfile +db.proto = tcp + +## The address of the database server. +## For example, MariaDB by default uses localhost:3306. +## db.addr = +db.addr = 127.0.0.1:3306 + +## If you configured the database server to connect to a unix socket file, +## then you should fill this field with the file name. +## db.socketfile = +db.socketfile = false + +## User name to connect to the database server. +## db.username = +db.username = root + +## Password of the user to connect to the database server. +## db.passwd = +db.passwd = + +## The database name. +## db.name = +db.name = artanis-example2 + +## The engine of the database server. +## NOTE: for sqlite3, you must leave this field blank, as `db.engine = ' +## If you remove this item, the default value InnoDB will be used. +## db.engine = +db.engine = InnoDB + +## The size of DB connection pool. If the specified size is less then required, +## then the task will be scheduled and sleep till there's available DB connection. +## db.poolsize = +db.poolsize = 64 + +## The management mode of DB connection pool: +## `increase' for increasing the pool size if any necessary, however it won't reduce back. +## `fixed' will not increase the pool size, if it lacks of DB connections, then it will +## be scheduled. +## db.pool = increase | fixed +db.pool = increase + +## Whether to encode params automatically. +## (params rc "your_key") will be encoded by uri-encode. +## The username and passwd in :auth will be encoded by uri-encode. +## NOTE: It's your duty to call uri-decode to get proper value. +## NOTE: If you enable db.encodeparams then it's better to decode the related value +## twice in the client-side, since some requests may be sent from browsers, and +## they're already encoded. +## db.encodeparams = +db.encodeparams = false + +## Enable LPC (Lightweight Persistent Cache), this may require Redis. +## db.lpc = +db.lpc = false + +## Specify your own server info. It'll be Artanis-x.x.x by default, adding +## the artanis version number. +## server.info = +server.info = GNU Artanis-1.2.2 + +## If you want to use Nginx for reversed-proxy, please enable it. +## server.nginx = enable | disable +server.nginx = false + +## Charset in server side. utf-8 in default. +## NOTE: Don't change it unless you know what you're doing! +## server.charset = +server.charset = utf-8 + +## The path of status page. You may customize your own status pages. +## If you're using application folder from `art create', then you may add your +## customized status pages in sys/pages, for example, if you create 404.html in +## sys/pages, then it will overload the original 404 page. +## server.syspage.path = +server.syspage.path = /etc/artanis/pages + +## Backlog of the socket. +## NOTE: Don't change it unless you really know what you're doing! +## server.backlog = +server.backlog = 128 + +## The length of the work queue in Artanis server. +## server.wqlen = +server.wqlen = 64 + +## The trigger mode of epoll. Please read epoll man page to know more. +## server.trigger = edge | level +server.trigger = edge + +## The server core which is used for holding high concurrent connections. +## Artanis has a strong server core named Ragnarok, which is based on +## delimited-continuations to provide asynchronous non-blocking high concurrent serving. +## You may choose guile inner server which is weak, but useful when you are running +## Artanis on an operating system lacking key features to run Raganrok. For example, +## in GNU/Hurd, which has no epoll. +## You may choose fibers server implemented with threads and delimited continuations, +## which is preemptable by the timer you set. +## For more details please see https://github.com/wingo/fibers/wiki/Manual. +## server.engine = ragnarok | guile | fibers | +server.engine = ragnarok + +## Timeout for any connection to Artanis (in seconds). +## 0 for always short live connections. +## server.timeout = +server.timeout = 60 + +## The the timeout for each event polling round, in miliseconds. +## server.polltimeout = +server.polltimeout = 500 + +## The buffer size (in bytes) of the connecting socket. +## In Ragnarok server core, the request handling will be scheduled when the socket +## buffer is full. This item affects the performance of socket I/O largely. +## Usually, if you're handling a large amount of small requests, it's better to set +## the buffer size to a small value. +## But if you're providing some kind of downloading or uploading service, it's better +## to set it to a larger one. +## A large buffer size will increase the latency of unserved requests. +## Please read the `Ragnarok server core' chapter to learn the design principle, +## if you need to do some tweaking. +## server.bufsize = +server.bufsize = 12288 + +## This is the most significant feature of Ragnarok server core. +## Please remember that there're no threads in GNU Artanis. +## All the tasks are based on delimited continuations, this kind of design is the +## so-called Green Threads, or modern terminology, Co-routines. +## GNU/Linux has introduced a feature named SO_REUSEPORT since 3.9. +## This feature let us start multiple Artanis instances listening to the same socket +## port. When requests come, the Linux kernel will do the necessary lock and allocation +## work for us to dispatch requests to these Artanis instances. +## server.multi = +server.multi = false + +## To specify the number of workers in the server core. Each worker implies a coroutine queue. +## The default value is 1, which means no threading at all. +## The throughput will be dramatically increased when you set it to a larger number. +## [Experimental] It's not well tested yet, but it does work. Here're known issues: +## 1. The main thread may be halted when ctrl+c is pressed, but it still work with other threads. +## 2. There could be potential race conditions, we've already use parameters for its functional nature +## to implement thread local storage. But need more tests. +## NOTE: If the workers is larger than 1, then it implies server.multi = true. +## server.workers = +server.workers = 1 + +## Enable WebSocket. +## server.websocket = +server.websocket = false + +## The path to public directory, this is useful for public static resources, +## for exaample, css/img/js, etc. +## server.pub = +server.pub = pub + +## Whether to use Linux specified sendfile interface. +## server.sendfile = +server.sendfile = false + +## Whether to use POSIX specific mmap for file I/O. +## server.mmapped = +server.mmapped = false + +## The allowed HTTP methods. +## server.allowedmethods = +server.allowedmethods = HEAD,GET,POST,PUT + +## The path to find "manifest.json". +## server.jsmanifest = +server.jsmanifest = pub + +## The maximum payload size of WebSocket request in bytes. If it exceeds, then it +## will be segemented. +## websocket.maxpayload = +websocket.maxpayload = 18446744073709551615 + +## The minimum payload size of WebSocket request in bytes. +## Enlarge it to avoid slow 1-byte attack (only for fragment). +## websocket.minpayload = +websocket.minpayload = 1 + +## If fragment >= 0, then it's the size of the websocket frame fragment. +## If fragment = 0, then the websocket frame will not be fragmented. +## websocket.fragment = +websocket.fragment = 4096 + +## Maximum upload size in bytes from WebSocket request, the exceeded request +## will be fobidden. +## websocket.maxsize = +websocket.maxsize = 1024 + +## Timeout of WebSocket request, in seconds. +## websocket.timeout = +websocket.timeout = 64 + +## If disabled, you will have to use the IP address to connect instead of the +## hostname. e.g. `host.name = lambdachip.com'. +## host.name = | disable +host.name = false + +## The URL/IP of your hosting site. +## host.addr = | +host.addr = 127.0.0.1 + +## The listening port of your hosting site. +## host.port = +host.port = 3000 + +## Specify the protocol family. +## host.family = ipv4 | ipv6 +host.family = ipv4 + +## Detect host or domain-name from specified path. This is useful when you run GNU Artanis inside a container. +## host.detectpath = | +host.detectpath = false + +## Specify the session files path. Change according to your session engine. +## session.path = +session.path = session + +## Check the valid session, if it appears in multiple client IP, then fail. This may +## cause problems when your hosting is behind CDN, you may need to disable it if so. +## session.hijackcheck = +session.hijackcheck = false + +## Specify session engine. Here're supported backends: +## simple: uses hash table for memcache. +## db: uses RDBMS for storing sessions. +## file: stores session information into text files. +## redis: uses Redis for managing sessions. +## session.engine = simple | db | file | redis | redis@addr:port | +session.backend = simple + +## Specify the i18n engine. Here're supported backends: +## 1. json: uses json file for i18n. +## 2. po: uses PO with gettext for i18n. +## session.i18n = json | po | +session.i18n = json + +## Specify allowed upload file type, say, upload.types = jpg,png,gif. +## upload.types = +upload.types = jpg,png,gif + +## The path to put the uploaded files. +## upload.path = +upload.path = upload + +## The size limitation of uploaded file in bytes. +## upload.size = +upload.size = 5242880 + +## The command called by Sendmail module. It's strongly recommended to use `msmtp' to replace `sendmail'. +## mail.sender = +mail.sender = /usr/bin/msmtp + +## The maximum age of a cached page in seconds. +## This is the global maxage of any cache. +## If you want to specify maxage for certain page, please read the manual about the Cache. +## cache.maxage = +cache.maxage = 3600 + +## Wheather to enable debug mode. +## If you enable debug mode, Artanis will print debug information verbosely. +## The module you modified will be reloaded instantly, and the page view will be rendered as well. +## NOTE: This option will affect the performance, please use it for debug purposes only./ +## debug.enable = +debug.enable = false + +## The paths that needs to be monitored in debug-mode. +## This will take advantage of `inotify' in GNU/Linux kernel. +## NOTE: We may support GNU/Hurd as well, with its file monitor mechanism, in the future. +## debug.monitor = +debug.monitor = + +## Cookie expiration time in seconds. +## 1 hour is 3600 +## 6 hours 21600 +## 1 month 2592000 +## cookie.expires = +cookie.expires = 3600 + + +## End Of Artanis conf. diff --git a/conf/plugins.scm b/conf/plugins.scm new file mode 100644 index 0000000..323035b --- /dev/null +++ b/conf/plugins.scm @@ -0,0 +1,8 @@ +;; This is a plugin configuration file, don't remove it! + +;; Uncomment following lines to enable plugins. +;; Make sure you import the plugin modules here. +(define-module (artanis plugins) + #:use-module (artanis oht)) + +;; (plugin-enable! name handler) diff --git a/db/.gitkeep b/db/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/db/migration/.gitkeep b/db/migration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/db/sm/.gitkeep b/db/sm/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/.gitkeep b/lib/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/log/.gitkeep b/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/prv/.gitkeep b/prv/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pub/.gitkeep b/pub/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pub/css/.gitkeep b/pub/css/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pub/img/.gitkeep b/pub/img/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pub/img/upload/.gitkeep b/pub/img/upload/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pub/js/.gitkeep b/pub/js/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sys/.gitkeep b/sys/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sys/i18n/.gitkeep b/sys/i18n/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sys/i18n/json/.gitkeep b/sys/i18n/json/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sys/i18n/po/.gitkeep b/sys/i18n/po/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sys/i18n/sxml/.gitkeep b/sys/i18n/sxml/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sys/pages/.gitkeep b/sys/pages/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/.gitkeep b/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/benchmark/.gitkeep b/test/benchmark/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/benchmark/README b/test/benchmark/README new file mode 100644 index 0000000..e69de29 diff --git a/test/functional/.gitkeep b/test/functional/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep new file mode 100644 index 0000000..e69de29