Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e98d87

Browse files
author
studygolang
committed
增加安装说明和一些方便的启动服务脚本;
1 parent 67602a3 commit 5e98d87

File tree

13 files changed

+135
-8
lines changed

13 files changed

+135
-8
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ studygolang
22
===========
33
[Golang中文社区 | Go语言学习园地](http://studygolang.com "Golang中文社区 | Go语言学习园地") 源码
44

5-
网址上线时间:2013-03-15 14:38:09
5+
网站上线时间:2013-03-15 14:38:09
66

77
目前只开发了主要功能,还有不少功能在不断开发中。欢迎有兴趣的gopher们参与进来,一起构建一个完善的 Golang 中文社区,Go语言爱好者的学习家园。
88

@@ -20,3 +20,49 @@ studygolang
2020
11. 资源
2121
12. 酷站
2222
13. 后台管理
23+
24+
# 本地搭建一个 Golang 社区 #
25+
26+
1、下载 studygolang 代码
27+
28+
git clone https://github.com/studygolang/studygolang
29+
30+
2、下载安装依赖库(如果依赖库下载不下来可以联系我)
31+
32+
cd studygolang/websites/code/thirdparty
33+
// windows 下执行
34+
getpkg.bat
35+
// linux/mac 下执行
36+
sh getpkg
37+
38+
3、编译并运行 studygolang
39+
40+
先编译
41+
42+
// 接着上一步
43+
cd ../studygolang/
44+
// windows 下执行
45+
install.bat
46+
// linux/mac 下执行
47+
sh install
48+
49+
这样便编译好了 studygolang,下面运行 studygolang。(运行前可以根据需要修改 config/config.json 配置)
50+
51+
// windows 下执行
52+
start.bat
53+
// linux/mac 下执行
54+
sh start
55+
56+
一切顺利的话,studygolang 应该就启动了。
57+
58+
4、浏览器中查看
59+
60+
在浏览器中输入:http://127.0.0.1:8080
61+
62+
应该就能看到了。
63+
64+
5、建立数据库
65+
66+
运行起来了,但没有建数据库。源码中有一个 databases 文件夹,里面有建表和初始化的sql语句。之前这些sql之前,在mysql数据库中建立一个数据库:studygolang,之后执行这些sql语句。
67+
68+
根据你的数据库设置,修改上面提到的 `config/config.json` 对应的配置,重新启动 studygolang.(通过restart脚本重新启动)

websites/code/studygolang/clean

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ ! -f clean ]; then
6+
echo 'clean must be run within its container folder' 1>&2
7+
exit 1
8+
fi
9+
10+
CURDIR=`pwd`
11+
OLDGOPATH="$GOPATH"
12+
export GOPATH="$CURDIR:$CURDIR/../thirdparty"
13+
14+
go clean -i -r studygolang
15+
16+
rm -rf pid
17+
rm -rf bin
18+
rm -rf pkg
19+
rm -rf log
20+
21+
export GOPATH="$OLDGOPATH"
22+
export PATH="$OLDPATH"
23+
24+
echo 'finished'

websites/code/studygolang/clean.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ goto end
99
:ok
1010

1111
set OLDGOPATH=%GOPATH%
12-
set GOPATH=%~dp0;
12+
set GOPATH=%~dp0;%~dp0..\thirdparty
1313

1414
go clean -i -r studygolang
1515

16+
rd /s /q pid
17+
rd /s /q bin
18+
rd /s /q pkg
19+
del /q /f /a log
20+
1621
set GOPATH=%OLDGOPATH%
1722

1823
:end

websites/code/studygolang/restart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ ! -f restart ]; then
6+
echo 'restart must be run within its container folder' 1>&2
7+
exit 1
8+
fi
9+
10+
sh stop
11+
sh start
12+
13+
echo 'restart successfully'

websites/code/studygolang/restart.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo off
2+
3+
setlocal
4+
5+
if exist restart.bat goto ok
6+
echo restart.bat must be run from its folder
7+
goto end
8+
9+
:ok
10+
11+
:: stop
12+
taskkill /im studygolang.exe /f
13+
del /q /f /a pid
14+
15+
:: start
16+
start /b bin\studygolang >> log\panic.log 2>&1 &
17+
18+
echo restart successfully
19+
20+
:end

websites/code/studygolang/start

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ if [ ! -f start ]; then
88
fi
99

1010
bin/studygolang >> log/panic.log 2>&1 &
11+
12+
echo "start successfully"

websites/code/studygolang/start.bat

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ goto end
88

99
:ok
1010

11-
START /b bin\studygolang >> log\panic.log 2>&1 &
11+
start /b bin\studygolang >> log\panic.log 2>&1 &
1212

13-
:end
14-
echo finished
13+
echo start successfully
14+
15+
:end

websites/code/studygolang/stop

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
if [ ! -f stop ]; then
4+
echo 'stop must be run within its container folder' 1>&2
5+
exit 1
6+
fi
7+
8+
kill -9 `cat pid/*.pid`
9+
10+
sleep 1
11+
rm -rf pid/*.pid

websites/code/studygolang/stop.bat

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ goto end
99
:ok
1010

1111
taskkill /im studygolang.exe /f
12-
del /q /f /a pid\studygolang.pid
12+
del /q /f /a pid
1313

14-
:end
15-
echo finished
14+
:end

websites/code/thirdparty/getpkg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ go get -u github.com/go-sql-driver/mysql
1414
go get -u github.com/studygolang/mux
1515
go get -u github.com/gorilla/sessions
1616

17+
hg clone https://code.google.com/p/go.net src/go.net
18+
go install go.net/websocket
19+
1720
export GOPATH="$OLDGOPATH"
1821
export PATH="$OLDPATH"
1922

websites/code/thirdparty/getpkg.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ set GOPATH=%~dp0
1414
go get -u github.com/go-sql-driver/mysql
1515
go get -u github.com/studygolang/mux
1616
go get -u github.com/gorilla/sessions
17+
hg clone https://code.google.com/p/go.net src/go.net
18+
go install go.net/websocket
1719

1820
set GOPATH=%OLDGOPATH%
1921

websites/code/thirdparty/install.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set GOPATH=%~dp0
1414
go install github.com/go-sql-driver/mysql
1515
go install github.com/studygolang/mux
1616
go install github.com/gorilla/sessions
17+
go install github.com/gorilla/go.net/*
1718

1819
set GOPATH=%OLDGOPATH%
1920

0 commit comments

Comments
 (0)