<commit_before># Beaker

Beaker is a simple blog system.

## Platforms

- Linux
- MacOS
- Windows(only cli)

## Install

### Build with source

You need install golang with v1.5.0.

Run command in terminal.

```
git clone https://github.com/mebiusashan/beaker.git
cd beake
./build.sh
```

Now you can find `bin` folder in current folder.If your server's os is Linux, please run command `cd linux`. If your server's os is MacOS, run command `cd darwin`.

You can see 2 executable files, `beaker_server` and `beaker_admin`. So you build system is success.

### Install Server

#### Create Database with MySQL

```
mysql>CREATE DATEBASE beaker;
```

#### Install beaker

You need have install folder in you server, like `/beaker`. If you want install beaker to `/www/blog`, Run command in terminal:

```
cd /beaker
./install.sh
Beaker
Please input your MySQL HOST:
localhost
Please input your MySQL Port:
3306
Please input your MySql user:
root
Please input your MySql password:
<PASSWORD>
Please input your MySql Database:
beaker
Please input your server path:
/www/blog
Please input your server user name:
beaker
Please input your server user password:
<PASSWORD>
Please input your server port:
9091
Please input your admin server port:
9092
Please input your domain: 
ashan.org
```

Now you install beaker is success, you can see `config.toml` file in `/www/blog/` and `admin/toml` file.

`config.toml` like this:

```
#配置文件

[website]
SITE_NAME = "Beaker"
SITE_URL = "ashan.org"
SITE_DES = "a simple blog system"
SITE_FOOTER = "Beaker is a simple blog system. [github.com/mebiusashan/beaker]"
SITE_KEYWORDS = "beaker, golang, blog"

#首页记录数量
INDEX_LIST_NUM = 30
TWEET_NUM_ONE_PAGE = 10
TEMP_FOLDER = "/www/blog/temp"
STATIC_FILE_FOLDER = "/www/blog/static/"

[server]
PORT = ":9091"
URL = "localhost"

[redis]
REDIS_IP = "127.0.0.1"
REDIS_PORT = "6379"
REDIS_PREFIX = "beaker_"
#设置7天的记录生命
EXPIRE_TIME = 25200

[database]
DB_URL = "localhost:3306"
DB_USER = "root"
DB_PW = "<PASSWORD>"
DB_NAME = "beaker"
MAX_IDLE_NUM = 10
MAX_OPEN_NUM = 100
```

`admin.toml`

```
[authinfo]
Name="beaker"
Password="<PASSWORD>"
ConfigPath="/www/blog/config.toml"
ServerKeyDir="/www/blog/keys/"
ClientKeyDir="/www/blog/keys/"

[server]
PORT = ":9092"
URL = "localhost"

[redis]
REDIS_IP = "127.0.0.1"
REDIS_PORT = "6379"
REDIS_PREFIX = "beaker_"
#设置7天的记录生命
EXPIRE_TIME = 25200

[database]
DB_URL = "localhost:3306"
DB_USER = "root"
DB_PW = "<PASSWORD>"
DB_NAME = "beaker"
MAX_IDLE_NUM = 10
MAX_OPEN_NUM = 100
```

You can change it.


## How to use

### Run server

You need installed beaker. If you beaker in `/www/blog`, run command in terminal:

```
export BEAKERPATH=/www/blog/config.toml
export BEAKERADMINPATH=/www/blog/admin/toml
./beaker_server
./beaker_admin
```

Open `localhost:9091` on brower.

### Run client cli<commit_msg>add pm2 config example<commit_after># Beaker

Beaker is a simple blog system.

## Platforms

- Linux
- MacOS
- Windows(only cli)

## Install

### Build with source

You need install golang with v1.5.0.

Run command in terminal.

```
git clone https://github.com/mebiusashan/beaker.git
cd beake
./build.sh
```

Now you can find `bin` folder in current folder.If your server's os is Linux, please run command `cd linux`. If your server's os is MacOS, run command `cd darwin`.

You can see 2 executable files, `beaker_server` and `beaker_admin`. So you build system is success.

### Install Server

#### Create Database with MySQL

```
mysql>CREATE DATEBASE beaker;
```

#### Install beaker

You need have install folder in you server, like `/beaker`. If you want install beaker to `/www/blog`, Run command in terminal:

```
cd /beaker
./install.sh
Beaker
Please input your MySQL HOST:
localhost
Please input your MySQL Port:
3306
Please input your MySql user:
root
Please input your MySql password:
<PASSWORD>
Please input your MySql Database:
beaker
Please input your server path:
/www/blog
Please input your server user name:
beaker
Please input your server user password:
<PASSWORD>
Please input your server port:
9091
Please input your admin server port:
9092
Please input your domain: 
ashan.org
```

Now you install beaker is success, you can see `config.toml` file in `/www/blog/` and `admin/toml` file.

`config.toml` like this:

```
#配置文件

[website]
SITE_NAME = "Beaker"
SITE_URL = "ashan.org"
SITE_DES = "a simple blog system"
SITE_FOOTER = "Beaker is a simple blog system. [github.com/mebiusashan/beaker]"
SITE_KEYWORDS = "beaker, golang, blog"

#首页记录数量
INDEX_LIST_NUM = 30
TWEET_NUM_ONE_PAGE = 10
TEMP_FOLDER = "/www/blog/temp"
STATIC_FILE_FOLDER = "/www/blog/static/"

[server]
PORT = ":9091"
URL = "localhost"

[redis]
REDIS_IP = "127.0.0.1"
REDIS_PORT = "6379"
REDIS_PREFIX = "beaker_"
#设置7天的记录生命
EXPIRE_TIME = 25200

[database]
DB_URL = "localhost:3306"
DB_USER = "root"
DB_PW = "<PASSWORD>"
DB_NAME = "beaker"
MAX_IDLE_NUM = 10
MAX_OPEN_NUM = 100
```

`admin.toml`

```
[authinfo]
Name="beaker"
Password="<PASSWORD>"
ConfigPath="/www/blog/config.toml"
ServerKeyDir="/www/blog/keys/"
ClientKeyDir="/www/blog/keys/"

[server]
PORT = ":9092"
URL = "localhost"

[redis]
REDIS_IP = "127.0.0.1"
REDIS_PORT = "6379"
REDIS_PREFIX = "beaker_"
#设置7天的记录生命
EXPIRE_TIME = 25200

[database]
DB_URL = "localhost:3306"
DB_USER = "root"
DB_PW = "<PASSWORD>"
DB_NAME = "beaker"
MAX_IDLE_NUM = 10
MAX_OPEN_NUM = 100
```

You can change it.

### PM2 config

```
module.exports = {
  apps: [{
    name: 'blog web server',
    cwd: "/www/blog",
    script: './beaker_server',
    env: {
	"BEAKERPATH":"/www/blog/config.toml"
    },
    watch: true
  }, {
    name: 'blog admin server',
    cwd: "/www/blog",
    script: './beaker_admin',
    env: {
	"BEAKERADMINPATH":"/www/blog/admin.toml"
    },
    watch: true
  }]
}

```


## How to use

### Run server

You need installed beaker. If you beaker in `/www/blog`, run command in terminal:

```
export BEAKERPATH=/www/blog/config.toml
export BEAKERADMINPATH=/www/blog/admin/toml
./beaker_server
./beaker_admin
```

Open `localhost:9091` on brower.

### Run client cli
{'fraction_non_alphanumeric': 0.12918739635157545, 'fraction_numerical': 0.027529021558872307, 'mean_word_length': 4.262652705061082, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 26, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1479665', 'n_tokens_mistral': 2412, 'n_tokens_neox': 2272, 'n_words': 690}