Skip to content

Commit

Permalink
Merge pull request #221 from evanlinjin/master
Browse files Browse the repository at this point in the history
Version 5.2
  • Loading branch information
Evan Lin authored Jan 11, 2018
2 parents 92e5297 + 318789d commit 3f8b12b
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 34 deletions.
45 changes: 25 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ COPY . /bbs

# `unsafe` flag used as work around to prevent infinite loop in Docker
# see https://github.com/nodejs/node-gyp/issues/1236
RUN npm install -g --unsafe @angular/cli && \
cd /bbs/static && \
yarn && \
npm run build
RUN cd /bbs/static && \
rm -rf package-lock.json && \
npm install -g --unsafe && \
npm run build --prod

## Skycoin BBS Image
FROM alpine:3.7

ENV DATA_DIR=/data \
MESSENGER_ADDR=35.227.102.45:8005 \
RPC_PORT=8996 \
CXO_PORT=8998 \
WEB_PORT=8080

RUN adduser -D skycoin
RUN mkdir /data
RUN chown skycoin: /data
RUN mkdir $DATA_DIR
RUN chown skycoin: $DATA_DIR

USER skycoin

Expand All @@ -32,19 +38,18 @@ COPY --from=build-go /go/bin/* /usr/bin/
COPY --from=build-node /bbs/static/dist /usr/local/bbs/static
# volumes

VOLUME /data
VOLUME $DATA_DIR
WORKDIR /

EXPOSE 8080 8998

CMD [ \
"bbsnode", \
"--public=true", \
"--memory=false", \
"--config-dir=/data", \
"--cxo-port=8998", \
"--enforced-messenger-addresses=35.227.102.45:8005", \
"--enforced-subscriptions=03588a2c8085e37ece47aec50e1e856e70f893f7f802cb4f92d52c81c4c3212742", \
"--web-port=8080", \
"--web-gui-dir=/usr/local/bbs/static" \
]
EXPOSE $RPC_PORT $CXO_PORT $WEB_PORT

CMD bbsnode \
--public=true \
--memory=false \
--config-dir=$DATA_DIR \
--rpc=true \
--rpc-port=$RPC_PORT \
--cxo-port=$CXO_PORT \
--enforced-messenger-addresses=$MESSENGER_ADDR \
--web-port=$WEB_PORT \
--web-gui-dir=/usr/local/bbs/static
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Skycoin BBS uses the [Skycoin CX Object System](https://github.com/skycoin/cxo)

[![Skycoin BBS Showcase 4 - YouTube](https://i.ytimg.com/vi/6ZqwgefYauU/0.jpg)](https://youtu.be/6ZqwgefYauU)

## Installation
## Install

### Go 1.9+ Installation and Setup

Expand Down Expand Up @@ -46,7 +46,7 @@ but it must be cloned to this path: `$GOPATH/src/github.com/skycoin/bbs`.

Building instructions for static files can be found in [static/README.md](./static/README.md).

## Running BBS Node
## Run

```bash
$ bbsnode
Expand All @@ -62,14 +62,47 @@ The script [`run.sh`](./run.sh) is provided as a convenient to run BBS, serving
$ ./run.sh
```

## Using Skycoin BBS
## Docker

There are currently two ways of interacting with Skycoin BBS.
* **Web interface thin client -** By default, the flag `-web-gui` is enabled. Hence, when BBS is launched, the web gui will be served at a port specified by `-web-port`. One can only submit and view content via the thin client.
Pull docker image.

* **Restful json api -** This is ideal for viewing/submitting content without a graphical user interface. Documentation for the api is provided as a [Postman](https://www.getpostman.com/) Collection located at [doc/bbs_postman_collection.json](doc/postman_collection.json) which can be viewed online at: [https://documenter.getpostman.com/view/985347/skycoin-bbs-v05/719YYTS](https://documenter.getpostman.com/view/985347/skycoin-bbs-v05/719YYTS). A brief written documentation is provided at [doc/api_explnation.md](./doc/api_explanantion.md).
```bash
$ docker pull skycoin/bbs
```

Create a docker volume.

```bash
$ docker volume create bbs-data
```

Run Skycoin BBS.

```bash
$ docker run -p 8080:8080 -p 8998:8998 -p 8996:8996 -v bbs0:/data skycoin/bbs
```

List network interfaces.

```bash
$ ifconfig
```

Use CLI.

```bash
# help menu
$ docker run skycoin/bbs bbscli -h

# interact with bbs node
$ docker run skycoin/bbs bbscli -a 172.17.0.1:8996 messengers discover
```

## Command-line interface

The Command-line interface is for administration control over the BBS node.

* **Command-line interface -** This is for administration tools. Detailed instructions are located at [cmd/bbscli/README.md](./cmd/bbscli/README.md).
Detailed instructions are located at [cmd/bbscli/README.md](./cmd/bbscli/README.md).

## Documentation

Expand Down
15 changes: 13 additions & 2 deletions cmd/bbscli/bbscli.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ import (
)

const (
Version = "5.1"
Version = "5.2"
)

var (
Port = 8996
Address = ""
)

func address() string {
return "[::]:" + strconv.Itoa(Port)
if Address != "" {
return Address
} else {
return "[::]:" + strconv.Itoa(Port)
}
}

func call(method string, in interface{}) error {
Expand All @@ -46,6 +51,12 @@ func main() {
Value: Port,
Destination: &Port,
},
cli.StringFlag{
Name: "address, a",
Usage: "rpc address of the bbs node, over-rides 'port, p' flag",
Value: Address,
Destination: &Address,
},
}
app.Commands = cli.Commands{
{
Expand Down
2 changes: 1 addition & 1 deletion cmd/bbsnode/bbsnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

const (
Version = "5.1"
Version = "5.2"

defaultConfigSubDir = ".skybbs"
defaultStaticSubDir = "static/dist"
Expand Down
2 changes: 1 addition & 1 deletion pkg/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
VERSION=5.1
VERSION=5.2
GOARCH=amd64
NAME=skycoin_bbs

Expand Down
20 changes: 18 additions & 2 deletions src/store/cxo/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"
"sync"
"time"
"github.com/skycoin/cxo/node/gnet"
)

const (
Expand Down Expand Up @@ -178,14 +179,29 @@ func (m *Manager) prepareNode() error {
for _, pk := range m.node.Feeds() {
c.Subscribe(pk)
}

m.file.SetConnectionStatus(c.Address(), true)
m.l.Printf("Connected to '%s'", c.Address())
}

c.OnCloseConnection = func(c *node.Conn) {
m.file.SetConnectionStatus(c.Address(), false)
m.l.Printf("Disconnected from '%s'", c.Address())

go func() {
time.Sleep(time.Second * 2)
m.node.Connect(c.Address())
for {
time.Sleep(time.Second * 2)
switch c, e := m.node.Connect(c.Address()); e {
case nil, gnet.ErrAlreadyListen:
return
default:
if c == nil {
m.l.Printf("Reconnecting due to error: '%s'", e.Error())
} else {
m.l.Printf("Reconnecting to `%s` due to error: '%s'", c.Address(), e.Error())
}
}
}
}()
}

Expand Down
2 changes: 1 addition & 1 deletion static/dist/ngsw-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"/scripts.2ada44d001a2fa97ca64.bundle.js": "5101a13dcce062b23a11302fa35a1f696a16e3c4",
"/styles.2d4560bcefdd3da68b61.bundle.css": "be6010d0d73dff3dc1b8372d5b423d8a3bc6343c",
"/favicon.ico": "63f338aec4bb5adb37a6fb1b311c65835912c22f",
"/assets/dust.png": "d0cd217d6531d84d578cd3a078957748359684fc",
"/assets/logo.svg": "c84d898508bcca59b2113a54eb3ec4229acae416",
"/assets/dust.png": "d0cd217d6531d84d578cd3a078957748359684fc",
"/assets/nodes.svg": "15c1bf6a8e8668683fa85bd75057bfaecffd1939",
"/index.html": "1312c017c1c98b525e394010cdefa42e3720ff71"
},
Expand Down

0 comments on commit 3f8b12b

Please sign in to comment.