Giter VIP home page Giter VIP logo

go-pttbbs's Introduction

go-pttbbs

This project intends to be the go implementation of pttbbs/pttbbs.

Collaborating with Ptt-official-app middlewares. go-pttbbs intends to be web-based bbs.

Getting Started

You can start with the swagger api and try the api.

You can copy the curl command from the link if you encounter CORS issue.

Docker-Compose

You can do the following to start with docker-compose:

  • copy docker_compose.env.template to docker_compose.env and modify the settings.
  • ./scripts/docker_initbbs.sh [BBSHOME] pttofficialapps/go-pttbbs:latest
  • docker-compose --env-file docker_compose.env -f docker-compose.yaml up -d
  • register SYSOP and pttguest (api.GUEST) at http://localhost:3456/v1/register
  • register your account at http://localhost:3456/register
  • login at http://localhost:3456/v1/login
  • telnet localhost 8888 and use the account that you registered.

Testing

./scripts/test.sh

Coverage

./scripts/coverage.sh

Running with run.sh

You can do the following to run with ./scripts/run.sh:

  • On Mac: put the following lines in /etc/sysctl.conf and reboot for 16M shared-mem:
    kern.sysv.shmmax=16777216
    kern.sysv.shmmin=1
    kern.sysv.shmmni=128
    kern.sysv.shmseg=32
    kern.sysv.shmall=4096
    
  • Check that we do have 16M shared-mem
    sysctl -a|grep shm
    
  • Init your own BBSHOME:
    ./scripts/docker_initbbs.sh [BBSHOME] pttofficialapps/go-pttbbs:latest
    
  • cp 02-config-run.go.template ptttype/02-config-run.go
  • cp 02-config.run.template.ini 02-config.run.ini
  • Setup BBSHOME in 02-config.run.ini
  • Do the following step ONLY IF you want to reset shared-mem: ipcrm -M 0x000004cc ipcrm -S 0x000007da
  • ./scripts/run.sh

Running in docker

You can do the following do run updated-code in docker:

  • Modify the docker-compose.yaml and add the expected ports and mount directory in volumes:

    ports:
      - "127.0.0.1:3456:3456"
      - "127.0.0.1:8889:8888"
      - "127.0.0.1:48764:48763"
      - "127.0.0.1:[local-port]:[docker-port]"
    volumes:
      - ${BBSHOME}:/home/bbs
      - [local absolute directory]:/home/[username]/go-pttbbs
    
  • do docker-compose

  • docker container ls and find the corresponding docker container

  • docker exec -it [container] /bin/bash

  • cd /home/[username]/go-pttbbs

  • ./scripts/run-in-docker.sh [docker-port]

Config

Some config-variables are required const in ptttype, to be defined as Cstr (IDLEN, PASSLEN, etc.)

For the normal config-variables, we use config.ini as the configuration.

For the const config-variables in ptttype, We use 00-config-[dev-mode].go with +build flag

00-config.ini

We use viper and .ini as our config-framework. 00-config.template.ini is the config-template file.

We have 3 files For every module with the config:

  1. 00-config.go: define the variables of the config.
  2. config.go: define the func of setting the variables from the config-file.
  3. config_util.go: helper functions. should be straightforward to follow.

00-config-[dev-mode].go

We can customized ptttype/00-config-default.go with the following steps:

  1. Copy 00-config-production.go.template to ptttype/00-config-production.go and change the +build and variables accordingly.
  2. cd go-pttbbs ; go build -tag [dev-mode]; cd ..

Swagger.sh

The swagger setup is based on flask-swagger, which is a python-project. You can do following for the swagger-api:

  1. setup the python virtualenv.
  2. cd apidoc; pip install . && pip uninstall apidoc -y && python setup develop; cd ..
  3. ./scripts/swagger.sh
  4. connect to http://localhost:8080

PiChuChen's go-bbs was the first repo in Ptt-official-app intending to be the backend. This repository is intending to have another approach to implement the go-version of the bbs.

go-pttbbs's People

Contributors

cftang0827 avatar chhsiao1981 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.