Skip to content

Commit

Permalink
Some build&run docs, repositories and version upgrades, print the def…
Browse files Browse the repository at this point in the history
…ault values in the CLI help.
  • Loading branch information
dbarashev committed Nov 7, 2023
1 parent 91cea4c commit 4cc3abc
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 10 deletions.
61 changes: 61 additions & 0 deletions cloud.ganttproject.colloboque/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Colloboque: GanttProject real-time collaboration server

This document gives an overview of a real-time collaboration server for GanttProject documents.

## Building and running the server

Colloboque server uses a couple of libraries from GanttProject. They are available in GanttProject GitHub packages, and
it is possible to build them locally.

### Building

If you want to use libs from GitHub Packages, you need to pass your GitHub username and Personal Access Token to the
Gradle when building Colloboque using project properties:

```bash
gradle -Pgpr.user=<GH_USERNAME> -Pgpr.key=<GH_PAT> build
```

You can save `gpr.user` and `gpr.key` options into the local `gradle.properties` file (don't commit it into the version control). The remaining gradle command in this doc assume that the access to the required libs/repositories is already configured.

Please refer to [GitHub Docs](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#using-a-published-package)
for details on Personal Access Token


### Environment

Colloboque requires an initialized PostgreSQL database. You can run a PostgreSQL instance using Docker:

```
docker run -d -p 5432:5432 --name dev-postgres -e POSTGRES_HOST_AUTH_METHOD=trust postgres
```

This will start Postgres on port 5432 with `postgres` super user and empty password. Initialize it using

```
cd src/main/resources/
psql -h localhost -U postgres -f ./init-colloboque-server.sql
```

### Running the server

The following command will show the available command line arguments:

```
gradle run --args='--help'
```

The default values are okay for the local development, so you can run the server with

```
gradle run
```

It should print to the console something like

```
> Task :run
14:49:38.771 DEBUG [Startup @ main] - Starting dev Colloboque server on port 9000
14:49:38.883 DEBUG [Startup @ main] - Connected to the database. PostgreSQL 15.3 (Debian 15.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
<=
```
12 changes: 10 additions & 2 deletions cloud.ganttproject.colloboque/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ val kotlinVersion: String by project

plugins {
id("application")
id("org.jetbrains.kotlin.jvm") version "1.7.21"
id("org.jetbrains.kotlin.jvm") version "1.9.10"
id("maven-publish")
id("org.jetbrains.kotlin.plugin.serialization") version "1.7.21"
}
Expand All @@ -19,6 +19,14 @@ application {
repositories {
google()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/bardsoftware/ganttproject")
credentials {
username = project.findProperty("gpr.user")?.toString() ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key")?.toString() ?: System.getenv("TOKEN")
}
}
mavenLocal()
}

Expand All @@ -37,7 +45,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jooq:jooq:3.17.5")
implementation("org.slf4j:slf4j-api:1.7.36")
implementation("com.github.ajalt.clikt:clikt:3.5.0")
implementation("com.github.ajalt.clikt:clikt:4.+")
implementation("org.nanohttpd:nanohttpd:2.3.1")
implementation("org.nanohttpd:nanohttpd-websocket:2.3.1")

Expand Down
2 changes: 1 addition & 1 deletion cloud.ganttproject.colloboque/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kotlinVersion=1.7.0
kotlinVersion=1.9.10
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ along with GanttProject. If not, see <http://www.gnu.org/licenses/>.
package cloud.ganttproject.colloboque

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.context
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.int
import com.github.ajalt.clikt.output.MordantHelpFormatter
import fi.iki.elonen.NanoHTTPD
import fi.iki.elonen.NanoHTTPD.Response.Status
import fi.iki.elonen.NanoWSD
Expand All @@ -43,13 +45,18 @@ import java.util.zip.CRC32
fun main(args: Array<String>) = DevServerMain().main(args)

class DevServerMain : CliktCommand() {
private val port by option("--port").int().default(9000)
private val wsPort by option("--ws-port").int().default(9001)
private val pgHost by option("--pg-host").default("localhost")
private val pgPort by option("--pg-port").int().default(5432)
private val pgSuperUser by option("--pg-super-user").default("postgres")
private val pgSuperAuth by option("--pg-super-auth").default("")

private val port by option("--port", help = "HTTP port to listen on").int().default(9000)
private val wsPort by option("--ws-port", help = "WebSocket port to listen on").int().default(9001)
private val pgHost by option("--pg-host", help = "Postgres host name").default("localhost")
private val pgPort by option("--pg-port", help = "Postgres port").int().default(5432)
private val pgSuperUser by option("--pg-super-user", help = "Postgres super user name").default("postgres")
private val pgSuperAuth by option("--pg-super-auth", help = "Postgres super user password").default("")

init {
context {
helpFormatter = { MordantHelpFormatter(it, showDefaultValues = true) }
}
}
override fun run() {
STARTUP_LOG.debug("Starting dev Colloboque server on port {}", port)

Expand Down

0 comments on commit 4cc3abc

Please sign in to comment.