place

package module
v0.0.0-...-6c4fcd1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

README

place

This project was inspired by r/Place. It is an online shared canvas where you can draw individual pixels.

The project is online at pl.g7kk.com.

How to host a Place

  1. You need to compile this Go program using the Go compiler.

  2. Run it and set the -root argument to the location of the web/root directory.

Other configuration options:

-root string
The directory with the web files. (default "./root")

-count int
The maximum number of connections. (default 64)

-width int
The width to create the canvas. (default 1024)

-height int
The height to create the canvas. (default 1024)

-load string
A png to load as the canvas. (If not set it creates a blank canvas)

-save string
The name to save the canvas. (default "./place.png")

-log string
The log file to write to. (If not set it will log to the command line)

-port string
The port the server listens at. (default ":8080")

-sinterval int
Save interval in seconds. (default 180)

Maintenance

I recomend setting up some scripts to easily restart the server or rollback the canvas.

Restart the server

This script kills the server and restarts it with the old canvas. This does not reset the canvas.
On my server I have this script set up as a cron job to run nightly to remove any lingering websocket connections.

cd ~/go/src/place/web
pkill place
~/go/bin/place -port :80 -load place.png &>place.log &
Rollback the canvas

This script rolls back the canvas to a previously saved image.

cd ~/go/src/place/web
pkill place
cp place_rollback.png place.png
~/go/bin/place -port :80 -load place.png &>place.log &

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PixelColor

type PixelColor struct {
	X     int         `json:"x"`
	Y     int         `json:"y"`
	Color color.NRGBA `json:"color"`
}

type Server

type Server struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewServer

func NewServer(img draw.Image, count int) *Server

func (*Server) GetImageBytes

func (sv *Server) GetImageBytes() []byte

func (*Server) HandleGetImage

func (sv *Server) HandleGetImage(w http.ResponseWriter, r *http.Request)

func (*Server) HandleGetStat

func (sv *Server) HandleGetStat(w http.ResponseWriter, r *http.Request)

func (*Server) HandleSocket

func (sv *Server) HandleSocket(w http.ResponseWriter, r *http.Request)

func (*Server) ServeHTTP

func (sv *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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