Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove prerender server #597

Merged
merged 19 commits into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ A stock system simulator game which use acgn characters as company.
3. type `meteor npm install` in project folder
4. type `meteor run --settings config.json` in project folder

### Turn to Production mode
## Documentation

Production mode requires `Headless Chrome`, so you need to install Chrome first.

Set `"production": true` in [config.json](config.json).
You can find more detail in [docs](docs).

## Contributors

Expand Down
7 changes: 3 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// 真正的設定檔請寫在config.json,這邊只是註解用。
export const config = {
debugMode: false, // 是否為debug mode(紀錄一分鐘內的所有方法與訂閱動作,以備crash查看)
production: false, // 是否在 production mode (production設定下需要安裝chrome以啟用所有功能)
websiteInfo: { // 網站資訊
websiteName: 'ACGN股票交易市場', // 網站名稱
description: '| 尋找你的老婆! \n| 喜歡嗎?那麼就入股吧!',
domainName: 'acgn-stock.com',
image: 'https://acgn-stock.com/ms-icon-310x310.png',
timezone: 8 // 主要客群所在的時區 (可能與server的時區不同)
},
prerenderServer: {
'url': 'http://127.0.0.1', // prerender的server位置
'port': '3900'
prerender: {
use: false, // 是否使用prerender功能 (需要另外架設prerender server)
url: 'http://127.0.0.1:3900/' // prerender server的位置
},
intervalTimer: 60000, // 每隔多少毫秒進行一次工作檢查
releaseStocksForHighPriceInterval: { // 高價釋股的排程時間範圍 (ms)
Expand Down
7 changes: 3 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"public": {
"debugMode": false,
"production": false,
"websiteInfo": {
"websiteName": "ACGN股票交易市場",
"description": "| 尋找你的老婆! \n| 喜歡嗎?那麼就入股吧!",
"domainName": "acgn-stock.com",
"image": "https://acgn-stock.com/ms-icon-310x310.png",
"timezone": 8
},
"prerenderServer": {
"url": "http://127.0.0.1",
"port": "3900"
"prerender": {
"use": false,
"url": "http://127.0.0.1:3900/"
},
"intervalTimer": 60000,
"releaseStocksForHighPriceInterval": {
Expand Down
75 changes: 75 additions & 0 deletions docs/prerender.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Prerender

`acgn-stock` can use [prerender](https://github.com/prerender/prerender-node) to help its SEO process.

Since the setup process is a little bit complicated, we wrote down this how-to document to help those in need.

## Setting Up a Prerender Server

To enable this functionality, you will need a **prerender server** to handle the request.

### Hosted Service

If you don't want to run your own prerender server, check out [PrerenderIO](https://prerender.io/) for their hosted service.

### Run Your Own Prerender Server

If you choose to run your own prerender server, follow these steps:

1. install [Chrome](https://www.google.com/chrome/)

[(Guide for installing Chrome on a Ubuntu server)](https://askubuntu.com/a/79284)

2. create a new node project and install [prerender](https://github.com/prerender/prerender)

```sh
npm install prerender --save
```

**IMPORTANT NOTE: Don't try to install prerender server in your `acgn-stock` project!**

We tried to integrate prerender into this project (see #589, #591). Since then we encountered some serious issues which prevent `acgn-stock` from working, so we decided to remove it (see #597).

3. write `index.js`
```js
const prerender = require('prerender');
const prerenderServer = prerender({
port: 3900,
waitAfterLastRequest: 3000
});
prerenderServer.start();
```

For the port, we use `3900` here. Feel free to switch to the other port if you want. Just make sure it's not being used.

For the `waitAfterLastRequest`, we recommend `3000`ms here. [(Check the document about `waitAfterLastRequest`)](https://github.com/prerender/prerender#waitafterlastrequest)

4. start the server

```sh
node index.js
```

After the server is started, you can connect to, for example, `http://localhost:3900/https://github.com/`, to see if it works.


## Setting Your `acgn-stock`

Update your prerender setting in [config.json](../config.json)

```json
"prerender": {
"use": true,
"url": "http://127.0.0.1:3900/"
}
```

`"use"` must be `true` if you want to use prerender.

`"url"` is the URL of the prerender server.

Now you can run your `acgn-stock`, and visit the following URL to see if it's working or not.

```
http://localhost:3000/company/1?_escaped_fragment_=
```
Loading