Moon Light Box

Time is Money

Koa2 - How to Use It?

| Comments

1. New Add Server.js and index.html(You can put it on folder "dist")

const fs = require('fs');
const path = require('path');
const Koa = require('koa');
const logger = require('koa-logger');
const serve = require('koa-static');
const compress = require('koa-compress');
const Router = require('koa-router');

const app = new Koa();

// https://github.com/koajs/static
const SERVE_OPTIONS = {
    maxage: 30 * 24 * 60 * 60 * 1000
};

const distFolder = path.resolve(__dirname, 'dist');

const root = new Router();
root.get('*', async (ctx) => {
    ctx.type = 'html';
    ctx.body = fs.createReadStream(`${distFolder}/index.html`);
});

const router = new Router();
router.use('/', root.routes(), root.allowedMethods());

app.use(logger());
app.use(compress());
app.use(serve(buildFolder, SERVE_OPTIONS));
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(80);

2. Execute it :)

# node Server.js

3. Browse http://127.0.0.1

Webpack3 - Set Production Building Configuration

| Comments

https://medium.com/netscape/webpack-3-react-production-build-tips-d20507dba99a

http://www.zcfy.cc/article/two-quick-ways-to-reduce-react-app-s-size-in-production-1930.html

https://webpack.js.org/plugins/

https://medium.com/rajaraodv/two-quick-ways-to-reduce-react-apps-size-in-production-82226605771a@

https://juejin.im/entry/57cd199467f3560057c99607

https://rhadow.github.io/2015/05/30/webpack-loaders-and-plugins/

http://foio.github.io/wepack-code-spliting/

https://loveky.github.io/2017/03/29/webpack-module-ids/

MariaDB - Re-Start Cluster Failed

| Comments

[ERROR] WSREP: It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates. To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1 .
// see https://severalnines.com/blog/how-bootstrap-mysqlmariadb-galera-cluster
--wsrep-recover

# vim /YOUR_MYSQL_DB_PATH/grastate.dat

# GALERA saved state
version: 2.1
uuid:    e02c98a9-e147-11e6-b6e9-e2d770b0c2ba
seqno:   -1
safe_to_bootstrap: 0 -> 1
# docker exec -it mariadb bash

SHOW STATUS LIKE 'wsrep_%';

mysql -u root -p

...
wsrep_incoming_addresses     | 10.10.10.10:3306,10.10.10.11:3306,10.10.10.12:3306
...
wsrep_local_state_comment    | Synced
...

https://severalnines.com/blog/how-bootstrap-mysqlmariadb-galera-cluster
http://benjr.tw/95413
https://dba.stackexchange.com/questions/151941/how-to-restart-mariadb-galera-cluster
http://zjzone.cc/index.php/2017/04/18/mariadb-galera-ji-qun-zi-dong-hui-fu-jiao-ben/