手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2015年04月23日的文章

gogs 如何不使用端口进行访问

gogos 默认是 3000端口,如果你本身已经有了其他WEB服务,比如apache,当然不可能同时占用80端口,这时候就可以利用apapche的proxy功能。如果你是apt-get 安装 的apache,就方便了,debian/ubuntu 都支持a2ensiate,a2enmod这样的小脚本。你只要打开a2enmod proxy proxy_http就行了,然后新建一个site加入以下配置

XML/HTML代码
  1. <VirtualHost *:80>  
  2.     ServerAdmin test@test.com  
  3.     ServerName yoursitename  
  4.     ProxyRequests off  
  5.     ProxyPass / http://127.0.0.1:3000/  
  6.     ProxyPassReverse / http://127.0.0.1:3000  
  7.     <Proxy *>  
  8.         Order Deny,Allow  
  9.         Allow from all  
  10.     </Proxy>  
  11.     ErrorLog ${APACHE_LOG_DIR}/yoursitename.log  
  12.     LogLevel warn  
  13. </VirtualHost>  
是不是很简单,这时候你用supervisor启动后就可以通过WEB访问了.不过这时候有具小缺点,那就是如果你killall gogs进程的话,你会发现再也启动不了了.看启动的LOG会告诉你3000端口被占用,用netstat -an|grep 3000,发现有N个进程都是在CLOSE_WAIT的情况,这时候用: echo $(netstat -anp|grep 127.0.0.1:3000 |awk '{print $7}') 发现,全是apache2占着这些进程.

怀疑刚才在强杀gogs进程的时候,apache因为开着proxy导致刚刚向3000端口发起请求就挂起,导致异常关闭所以一直卡住(以前用nginx的做反代的时候也有类似问题,只要客户机挂了,nginx必须 重启),所以我重启了一下apache,立刻发现gogs启动成功.

至此,如果要 重启gogs最好是/etc/init.d/supervisor restart ,如果不正常就再重启一下apache...

OK,问题全部解决

 

Tags: gogs, apache

gogs 0.6.1版二进制打包文件缺少start.sh

在gogs的release包中,linux_amd64.zip这个包里,scripts目录下没有start.sh这个文件,因此在 执行./scripts/gogs_supvisor.sh文件的时候会直接后/usr/local/bin/gogs_start文件不存在

打开这个gogs_supvisor.sh文件后,发现他会判断/usr/local/bin/gogs_start文件是否存在,如果不存在就将./scripts/start.sh文件复制 过去并改为为gogs_start

然而,scripts目录下并没有这个start.sh文件,这个问题在官方的issue中已经提出并有解决方案:https://github.com/gogits/gogs/issues/1198

解决方案就是:

XML/HTML代码
  1. oh man sorry for that.  
  2.   
  3. I would suggest install supervisor as init.d somehow doesn't worked for me after trying lot of diffrent combinations. to do that,  
  4.   
  5. sudo apt-get -y install supervisor  
  6.   
  7. and edit its file via  
  8.   
  9. sudo nano /etc/supervisor/supervisord.conf  
  10.   
  11. [program:gogs]  
  12. directory=/home/git/go/src/github.com/gogits/gogs/  
  13. command=/home/git/go/src/github.com/gogits/gogs/gogs web  
  14. autostart=true  
  15. autorestart=true  
  16. startsecs=10  
  17. stdout_logfile=/var/log/gogs/stdout.log  
  18. stdout_logfile_maxbytes=1MB  
  19. stdout_logfile_backups=10  
  20. stdout_capture_maxbytes=1MB  
  21. stderr_logfile=/var/log/gogs/stderr.log  
  22. stderr_logfile_maxbytes=1MB  
  23. stderr_logfile_backups=10  
  24. stderr_capture_maxbytes=1MB  
  25. environment = HOME="/home/git", USER="git"  
  26.   
  27. change directory's to match your installation and user to your git user. and restart the supervisor via,  
  28. sudo service supervisor restart  
  29.   
  30. that's all you need to make gogs start automatically on boot.  

看上述内容,修改一下supervisor的配置,加入gogs的配置,注意修改成你自己的路径即可

Tags: gogs