Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 55 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: coursier/cache-action@v7
- uses: actions/checkout@v3
- uses: coursier/cache-action@v6
- name: out folder cache
uses: actions/cache@v3
with:
path: ./out
key: out-folder-cache
- name: Install Dependencies
run: |
curl -sL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
echo "deb https://packages.nginx.org/unit/ubuntu/ noble unit" | sudo tee -a /etc/apt/sources.list.d/unit.list
echo "deb-src https://packages.nginx.org/unit/ubuntu/ noble unit" | sudo tee -a /etc/apt/sources.list.d/unit.list
sudo apt-get update
sudo apt-get install -y libidn2-dev
unit_version="1.34.*"
sudo apt-get install -y libuv1-dev libidn2-dev unit=$unit_version unit-dev=$unit_version
- name: Download dependencies
run: |
./mill __.prepareOffline + __.resolvedMvnDeps
./mill __.prepareOffline
- name: Check formatting
run: |
./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
Expand All @@ -28,12 +37,26 @@ jobs:
- name: Run Unit Tests
run: ./mill snunit.test
- name: Run Integration Tests
run: ./mill integration.test
run: |
sudo systemctl stop unit.service
./mill integration.test
- name: Start NGINX Unit daemon
run: sudo systemctl start unit.service
# TODO: Enable again
# - name: Run Mill Plugin Tests
# run: ./mill -i snunit-mill-plugin.__.test

# - name: Build and Test Sbt plugin
# run: |
# (
# cd sbt-plugin
# sudo systemctl start unit.service
# sbt scalafmtCheckAll scalafmtSbtCheck scripted
# )
check-binary-compatibility:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Binary Compatibility
Expand All @@ -44,29 +67,35 @@ jobs:
needs: build
runs-on: ubuntu-24.04
env:
SONATYPE_PGP_PRIVATE_KEY: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY }}
SONATYPE_PGP_PRIVATE_KEY_PASSWORD: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY_PASSWORD }}
PGP_PASSPHRASE: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY_PASSWORD }}
PGP_SECRET: ${{ secrets.SONATYPE_PGP_PRIVATE_KEY }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
LANG: "en_US.UTF-8"
LC_MESSAGES: "en_US.UTF-8"
LC_ALL: "en_US.UTF-8"
steps:
- uses: actions/checkout@v5
- uses: coursier/cache-action@v7
- name: Publish to Maven Central
run: |
if [[ $(git tag --points-at HEAD) != '' ]]; then
echo $SONATYPE_PGP_PRIVATE_KEY | base64 --decode > gpg_key
gpg --import --no-tty --batch --yes gpg_key
rm gpg_key
./mill mill.scalalib.SonatypeCentralPublishModule/publishAll \
--username "$SONATYPE_USER" \
--password "$SONATYPE_PASSWORD" \
--gpgArgs "--passphrase=$SONATYPE_PGP_PRIVATE_KEY_PASSWORD,--no-tty,--pinentry-mode,loopback,--batch,--yes,-a,-b" \
--publishArtifacts __.publishArtifacts \
--readTimeout 36000 \
--awaitTimeout 36000 \
--connectTimeout 36000 \
--shouldRelease true
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: coursier/cache-action@v6
- name: Compilation cache
uses: actions/cache@v2
with:
path: ./out
key: out
- name: Publish plugin shared locally
run: ./mill snunit-plugins-shared.__.publishLocal
- run: ./mill io.kipp.mill.ci.release.ReleaseModule/publishAll
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
# TODO: Support again Sbt plugin once Mill plugin is stable
# - name: Publish Sbt Plugin
# run: |
# if [[ $(git tag --points-at HEAD) != '' ]]; then
# cd sbt-plugin
# sbt publishSigned sonatypeBundleRelease
# fi
1 change: 1 addition & 0 deletions .mill-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.14
5 changes: 5 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
version = "3.8.3"
maxColumn = 120
runner.dialect = scala3
fileOverride {
"glob:**/*.mill.scala" {
runner.dialect = scala213
}
}
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,71 @@ def run =

SNUnit is a Scala Native library to write HTTP server applications on top of
[NGINX Unit](https://unit.nginx.org/). It allows you to write both synchronous
and asynchronous web servers with great performance.
and asynchronous web servers with automatic restart on crashes, automatic
load balancing of multiple processes, great performance and all the nice
[NGINX Unit features](http://unit.nginx.org/#key-features).

## Running your app

Once built your SNUnit binary, you need to deploy it to the `unitd` server.

You need to run `unitd` in a terminal with:

```bash
unitd --no-daemon --log /dev/stdout --control unix:control.sock
```

This will run `unitd` with a UNIX socket file named control.sock in your current directory.

Then, you need to create a json file with your configuration:

```json
{
"listeners": {
"*:8081": {
"pass": "applications/myapp"
}
},
"applications": {
"myapp": {
"type": "external",
"executable": "snunit/binary/path"
}
}
}
```

Where `executable` is the binary path which can be absolute or relative
to the `unitd` working directory.

This configuration passes all requests sent to the port `8081` to the application `myapp`.

To know more about configuring NGINX Unit, refer to [its documentation](http://unit.nginx.org/configuration).

To deploy the setting you can use curl:

```bash
curl -X PUT --unix-socket control.sock -d @config.json localhost/config
```

If everything went right, you should see this response:

```json
{
"success": "Reconfiguration done."
}
```

In case of problems, you will get a 4xx response like this:

```json
{
"error": "Invalid configuration.",
"detail": "Required parameter \"executable\" is missing."
}
```

Further information can be found in `unitd` logs in the running terminal.

## Sync and async support

Expand Down
Loading
Loading