swi-server

command module
v0.0.0-...-0db08f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2023 License: GPL-2.0 Imports: 14 Imported by: 0

README

Street Wars Inc - Server

SWI is made as a spiritual successor to the original Street Wars Online 2, from 2000, and was created as a means to learn about GO and protobufs.

Also see the SWI Client and the SWI Protobufs

Overview

Server is written in Go, uses Protobufs and WebSockets for server/client communication, and SQLite as the DB (supports Turso). The client is a very basic site written in Svelte/TS. I cannot speak on performance or how optimised the server is VS could be, but I did make some decisions based on what would be more performant.

Setup/Install

In order to run the server we need 2 things:

1. TLS Certificate.

If you are running locally you can generate a selfsigned certificate for "localhost" by running:

bash ./generate-certificate.sh

For production environments it ... should... automatically generate a cert via LetsEncrypt. If you are using Cloudflare, you can generate an Origin Certificate for your domain, and put it in the ./certs directory at the swi-server root.

2. Database

You can sign up for free for a database at Turso.tech or create a new .db file at the swi-server root.

Then import the internal/databate/migration.sql file, you can use a tool like Atlast for migrations if you wish, there are Turso support as well. I have included an atlas.hcl config file.

Run
Development

run: go run . --dburl "libsql://...." --env dev --domain localhost
--dburl Is the url / path to your database
--env choose between dev and prod, it only changes the log level.
--domain tells the server which domain cert it should load in.

Production

Build for your platform: env GOOS=linux GOARCH=arm64 go build chaning GOOS and GOARCH with your platform.

run: swi-server --dburl "libsql://...." --env prod --domain <domain>

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL