Skip to content

Commit ea2ebc8

Browse files
committed
增加中文帮助
1 parent 6d9ec2d commit ea2ebc8

2 files changed

Lines changed: 85 additions & 2 deletions

File tree

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,86 @@ daemon
22
======
33

44
A utility, make a command line tool run as a service on windows.
5+
6+
# Installation #
7+
8+
### Install required development components
9+
Require _Visual Studio 2003 and later_ or _Windows SDK_, or even [Microsoft Visual C++ Compiler for Python 2.7](https://www.microsoft.com/en-us/download/details.aspx?id=44266).
10+
11+
### Compile
12+
* Visual Studio just open the solution file
13+
14+
* Without Visual Studio, you need CMake to generate Makefile
15+
```bash
16+
daemon>mkdir build
17+
daemon>cd build
18+
daemon\build>cmake.exe -G "NMake Makefiles" ..
19+
daemon\build>nmake
20+
```
21+
22+
23+
24+
# Usage #
25+
26+
Usage: daemon.exe [cmdline]
27+
-c configuration file, default .\daemon.ini
28+
-f run foreground
29+
-d run as a background service
30+
-i install service
31+
-u uninstall service
32+
-r start service
33+
-k kill service
34+
-h show this help
35+
36+
37+
中文帮助
38+
=======
39+
40+
这个小工具作为 Windows 服务启动——在 vista 及以上系统是自动延迟启动,可以守护多个小程序——最多63个。如果子进程挂掉了,会再启动一个。
41+
42+
在 daemon.exe 目录下放置同名 daemon.ini 配置文件,样例如下:
43+
```ini
44+
[Settings]
45+
ServiceName=ASpecialDeamon
46+
DisplayName=A Special Deamon
47+
Description=long description
48+
; 本地系统(LocalSystem 账号是最高权限) ServiceStartName=
49+
; 本地服务 ServiceStartName=NT AUTHORITY\LocalService
50+
; virtual accounts (win7支持,更好的与其它用户隔离) ServiceStartName=NT SERVICE\your service name
51+
; 网络服务 ServiceStartName=NT AUTHORITY\NetworkService
52+
ServiceStartName=
53+
CheckProcessSeconds=30
54+
55+
; 服务启动时候,会将自己切换到 daemon.exe 所在目录,所以 CommandLine 最好使用绝对路径
56+
[Process0]
57+
; 定期执行 ping (因为子进程退出后会被自动启动)
58+
CommandLine=ping qq.com
59+
...
60+
[Process61]
61+
; 守护 mproxy,当前目录
62+
CommandLine=mproxy "-l8888" "-b127.0.0.1" "-s9.9.9.9" "-p60000" -k "your_key" "-maes-256-cfb" "--pac" "proxy.pac"
63+
[Process62]
64+
; 守护 kcptun,绝对路径
65+
CommandLine="D:\Program Files\kcptun\kcptun.exe" -r 9.9.9.9:9999 --key your_key --crypt aes --datashard 0 --parityshard 0 -l 0.0.0.0:8081
66+
```
67+
68+
* 安装服务
69+
```bash
70+
daemon.exe -i
71+
```
72+
73+
* 启动服务
74+
```bash
75+
daemon.exe -r
76+
```
77+
78+
* 停止服务
79+
```bash
80+
daemon.exe -k
81+
```
82+
83+
* 卸载服务
84+
```bash
85+
daemon.exe -u
86+
```
87+

daemon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void run_server()
360360
assert(processes_to_wait[idx]->pi.hProcess == process_handles[idx]);
361361
if (GetExitCodeProcess(process_handles[idx], &ec))
362362
{
363-
Log(LOG_LEVEL_INFO, _T("Process [%u] have exited with exit code (%u)\n"), processes_to_wait[idx]->pi.dwProcessId, ec);
363+
Log(LOG_LEVEL_INFO, _T("Process [%u] have exited with exit code (%u)"), processes_to_wait[idx]->pi.dwProcessId, ec);
364364
}
365365

366366
// Close process and thread handles.
@@ -397,7 +397,7 @@ void stop_server()
397397

398398
if(!SetEvent(handles[idx_action]))
399399
{
400-
Log(LOG_LEVEL_ERROR, _T("SetEvent failed (%d)\n"), GetLastError());
400+
Log(LOG_LEVEL_ERROR, _T("SetEvent failed (%d)"), GetLastError());
401401
}
402402
}
403403

0 commit comments

Comments
 (0)