/scala.native.nginx

Scala Native Nginx Unit server and client built on an Apple M1 using Sttp and Scala 3.

Primary LanguageScalaApache License 2.0Apache-2.0

Scala Native Nginx

Scala Native Nginx Unit server and client built on an Apple M1 using Sttp and Scala 3.

Note

This project is currently broken until com.github.lolgab" %%% "snunit supports Scala Native 0.5.1.

Install

See http://www.scala-native.org/en/latest/user/setup.html for details.

  1. brew install llvm
  2. brew install bdw-gc
  3. brew install nginx/unit/unit

Start, Verify and Stop Nginx Unit

  1. start: nohup unitd --no-daemon --log /dev/stdout --control unix:control.sock &
  2. verify: ps ax | grep unitd
  3. stop: Ctrl-C

Build, Install and Deploy NowServer

  1. sbt clean compile nativeLink
Multiple main classes detected. Select one to run:
 [1] objektwerks.NowClient
 [2] objektwerks.NowServer

Enter number: 2
  1. mv target/scala-3.3.1/scala-native-nginx-out target/scala-3.3.1/now-server
  2. sudo cp target/scala-3.3.1/now-server /usr/local/bin
  3. nohup unitd --no-daemon --log /dev/stdout --control unix:control.sock & (start nginx unit, if stopped)
  4. ./deploy.sh ( chmod 755 deploy.sh )

See config.json for Nginx Unit and NowServer config.

Build and Install NowClient

  1. sbt clean compile nativeLink
Multiple main classes detected. Select one to run:
 [1] objektwerks.NowClient
 [2] objektwerks.NowServer

Enter number: 1
  1. mv target/scala-3.3.1/scala-native-nginx-out target/scala-3.3.1/now-client
  2. sudo cp target/scala-3.3.1/now-client /usr/local/bin

NowClient Test

  1. nohup unitd --no-daemon --log /dev/stdout --control unix:control.sock & (start nginx unit, if stopped)
  2. now-client [ url ] ( the default NowServer url is detailed in config.json )

Curl Test

  1. nohup unitd --no-daemon --log /dev/stdout --control unix:control.sock & (start nginx unit, if stopped)
  2. curl http://localhost:7474/
  3. kill -9 pid ( rm control.sock nohup.out )

Resources

  1. Scala Native Docs
  2. Scala Native Intro Video
  3. NUnit
  4. SNUnit
  5. Sttp Native