在windows下编译nginx 2013-04-12
又有人在windows下编译nginx – 为什么那么多人喜欢自残呢?
官网教程
Building nginx on the Win32 platform with Visual C
本文基本上就是对着做,但需要对其进行微调 – 不爽吗?咬我啊!!
准备工具
系统: winxp sp3 32位, 例如你可以用个虚拟机什么的安装一个winxp
本站由Gor生成
又有人在windows下编译nginx – 为什么那么多人喜欢自残呢?
Building nginx on the Win32 platform with Visual C
本文基本上就是对着做,但需要对其进行微调 – 不爽吗?咬我啊!!
系统: winxp sp3 32位, 例如你可以用个虚拟机什么的安装一个winxp
源于golang群中再次提到windows下获取磁盘空间的方法
由于golang的api并非完全跨平台, golang本身并没有直接提供windows下的方式
当前共5个方法
syscall.Syscall
syscall.Syscall6
syscall.Syscall9
syscall.Syscall12
syscall.Syscall15
分别对应 3个/6个/9个/12个/15个参数或以下的调用
上周为了重写公司的其中一个关键进程,断然选用Python快速开发了一版
虽然python脚本可以直接启动,但为了兼容其他进程,需要封装成一个原命名的进程
#include <Python.h>
#include <sched.h>
int main(int argc, char *argv[]) {
//设置进程优先级,因为有其他更重要的进程
nice(10);
// 设置cpu亲和性,因为是4线程的机器,所以仅亲和后2个cpu
cpu_set_t mask;
CPU_ZERO(&mask);
CPU_SET(2, &mask);//第3个
CPU_SET(3, &mask);//第4个,其实就是第二个core
sched_setaffinity(0, sizeof(mask), &mask);
Py_SetProgramName(argv[0]);
Py_Initialize(); //标准的啦,初始化Python环境
PySys_SetArgv(argc, argv);
FILE * fp = fopen("/home/xxx/yyy/zzz.py", "r"); //打开入口py脚本的句柄,准备打开
// 这里并没有去判断是否真的存放,因为必须存放,不然也什么都做不了
//PyRun_SimpleFile(fp, "zzz.py");
PyRun_AnyFile(fp, "zzz.py"); //启动之,哈哈
Py_Finalize(); // 严格来说从不调用,哈哈,因为是守护进程,退出的话,都是直接退
return 0;//符合标准C嘛,哈哈
}
package main
import (
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://mirrors.ustc.edu.cn/opensuse/distribution/12.3/iso/openSUSE-12.3-GNOME-Live-i686.iso")
if err != nil {
panic(err)
}
fmt.Println("Resp code", resp.StatusCode)
resp.Body.Close() // 注意,这里并不读取resp.Body, 而resp.Body有大概700mb未读取
}
玩了一天,还是忍不住要root掉的. 实在无法忍受那些百度的app!!!
官网,木有 常见论坛,木有
最后,在592zn找到了 天语T619官方固件+592zn带ROOT固件
接下来,当然是root固件啦: 用yaffey 修改好,刷机,搞定!!
接下来,就是各种删除,哈哈
脱离了libyaml引入的cgo限制, 使用纯golang实现, 实现真正的跨平台
下载地址 已编译好的linux/windows/macx下的二进制程序
当然, 也可以通过go install来安装
go get -u github.com/wendal/gor
go install github.com/wendal/gor/gor
人家官方说了:
"This, among other reasons, to prevent programmers
for simulating thread local storage using the goroutine id as a key. "
就为了避免咱们当成ThreadLocal的key!! 这是为了神马?为神马?!!
神马?!改源码这么大件事?! 对的,但只是添加,不修改不覆盖,不影响其他功能
文件一, $GOPATH/src/pkg/runtime/runtime.c, 在最后面添加一个方法
void
runtime·GetGoId(int32 ret)
{
ret = g->goid;
USED(&ret);
}
所有操作均为root用户.
系统环境: Ubuntu 11.10 Desktop 32位 硬件环境: Nvidia GT540M 注意!! 虚拟机是不行的!!
wget http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_linux_32_ubuntu11.10-1.run
#当然,我更喜欢用QQ旋风之类的先下载好
#无需额外下载显卡驱动, cuda 5.0已经包含了最适合的显卡驱动
Nutz.Json的解析器分2部分, String->MapList, MapList->Pojo
单纯对一个简单的json字符串执行String->Map操作
改造前(3~4x)
Nutz-Json 500w次耗时: 14288
Fast-Json 500w次耗时: 4330
Nutz-Json 500w次耗时: 12336
Fast-Json 500w次耗时: 3029
改造后(1.3~1.6x)
Nutz-Json 500w次耗时: 6033
Fast-Json 500w次耗时: 4618
Nutz-Json 500w次耗时: 4717
Fast-Json 500w次耗时: 3048
纠结啊纠结啊…
出错信息非常长(几百~上千个goroutine),就只贴头尾
runtime/cgo: pthread_create failed: Resource temporarily unavailable
SIGABRT: abort
PC=0xffffe424
goroutine 1 [chan receive]:
net.(*pollServer).WaitRead(0xd0170f0, 0xd02e850, 0xcfff5e0, 0xb)
/opt/go/src/pkg/net/fd.go:268 +0x75
net.(*netFD).accept(0xd02e850, 0x80923d3, 0x0, 0xcfc0320, 0xcf7b178, ...)
/opt/go/src/pkg/net/fd.go:622 +0x199
net.(*TCPListener).AcceptTCP(0xd030358, 0xcfc0d20, 0x0, 0x0)
/opt/go/src/pkg/net/tcpsock_posix.go:320 +0x56
net.(*TCPListener).Accept(0xd030358, 0x0, 0x0, 0x0, 0x0, ...)
/opt/go/src/pkg/net/tcpsock_posix.go:330 +0x39
net/http.(*Server).Serve(0xd0170c0, 0xcfff920, 0xd030358, 0x0, 0x0, ...)
/opt/go/src/pkg/net/http/server.go:1029 +0x77
net/http.(*Server).ListenAndServe(0xd0170c0, 0xd0170c0, 0x40)
/opt/go/src/pkg/net/http/server.go:1019 +0x9f
net/http.ListenAndServe(0x81f73c4, 0x5, 0xcfff840, 0xd0301f8, 0xd0301f8, ...)
/opt/go/src/pkg/net/http/server.go:1091 +0x55
尾部
eax 0x0
ebx 0x231f
ecx 0x2357
edx 0x6
edi 0xb77ceff4
esi 0xb
ebp 0xafa112f8
esp 0xafa11050
eip 0xffffe424 //就这个,虽然不知道是什么,但很厉害的样子
eflags 0x202
cs 0x73
fs 0x0
gs 0x33