macOS gogs 安装

2018-12-30  本文已影响0人  devVector

gogs官网

需求

个人代码仓库,文档仓库(macdown 文件)

为什么使用gogs

维度 gitlab gogs
Mac支持 Mac上安装失败 Go语言写的,兼容各个系统
依赖 Nginx 、postgresql、redis 等等 git, 数据库可以用sqlite
资源占用 Gitlab 配置要求CPU两核,内存4G以上 x

因为是个人使用,相比gitlab gogs 更轻,更易配置

安装过程

下载安装

配置启动

//主目录, 我在共享目录下新建了个App文件夹, 用来放一些app 还有 app 的数据
/Users/vector/App/gogs

//应用目录
/Users/vector/App/gogs/bin  

//应用数据
/Users/vector/App/gogs/data  


//这里效仿apple sandbox, 在data目录下新建了2个文件夹 Documents、Library

// Gogs应用数据库
/Users/vector/App/gogs/data/Documents 

//Gogs应用数据
/Users/vector/App/gogs/data/Gogs/Library  

在gogs 可执行文件(/Users/vector/App/gogs/bin/gogs )同级目录(/Users/vector/App/gogs/bin/) 下新建文件夹 custom(/Users/vector/App/gogs/bin/custom), 新建目录 conf, 创建 app.ini 文件(/Users/vector/App/gogs/bin/custom/conf/app.ini), 编辑 app.ini (完整实例)

; App name that shows on every page title
APP_NAME = GitServer
; The name of the system user that runs Gogs
RUN_USER = vector
; Either "dev", "prod" or "test"
RUN_MODE = prod

[server]
; HTTP support
PROTOCOL         = http
DOMAIN           = code.xxx.com
ROOT_URL         = http://code.xxx.com:7880/
HTTP_ADDR        = 192.168.11.2
HTTP_PORT        = 7880
; SSH support
DISABLE_SSH      = false
SSH_DOMAIN       = code.xxx.com
SSH_PORT         = 7822
START_SSH_SERVER = true
SSH_ROOT_PATH    = /User/vector/.ssh
OFFLINE_MODE     = false
REWRITE_AUTHORIZED_KEYS_AT_START = false

[repository]
ROOT = /Users/vector/App/gogs/data/Library

[database]
; Either "mysql", "postgres" or "sqlite3", you can connect to TiDB with MySQL protocol
DB_TYPE  = sqlite3
PATH     = /Users/vector/App/gogs/data/Documents/gogs.db

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /Users/vector/App/gogs/bin/log

ROOT_URL 是我本地的域名,由于我本地搭建了dns服务器, 所以这里用的域名

/Users/vector/App/gogs/bin/gogs web

2018/12/31 02:23:41 [TRACE] Custom path: /Users/vector/App/gogs/bin/custom
2018/12/31 02:23:41 [TRACE] Log path: /Users/vector/App/gogs/bin/log
2018/12/31 02:23:41 [TRACE] Build Time: 2018-06-06 01:47:22 UTC
2018/12/31 02:23:41 [TRACE] Build Git Hash: 91441c3fb29d8ead645d8fffa4658d749d5b3fc3
2018/12/31 02:23:41 [TRACE] Log Mode: File (Trace)
2018/12/31 02:23:41 [ INFO] GitServer 0.11.53.0603

创建 /Users/vector/Library/LaunchAgents/gogs.plist 文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/vector/App/gogs/bin/gogs</string>
        <string>web</string>
    </array>
    <key>SoftResourceLimits</key>
    <dict>
        <key>NumberOfFiles</key>
        <integer>65536</integer>
    </dict>
    <key>StandardErrorPath</key>
    <string>/Users/vector/App/gogs/bin/log/stderr.log</string>
    <key>StandardOutPath</key>
    <string>/Users/vector/App/gogs/bin/log/stdout.log</string>
    <key>WorkingDirectory</key>
    <string>/Users/vector/App/gogs/</string>
    <key>UserName</key>
    <string>vector</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>io.gogs.web</string>
</dict>
</plist>

加载

launchctl load /Users/vector/Library/LaunchAgents/gogs.plist

问题

mac 折腾系列

上一篇下一篇

猜你喜欢

热点阅读