搬砖小抄

以windows服务的方式运行FRP

字数统计: 558阅读时长: 2 min
2020/07/21 Share

前几天看见有人在frp提工单问是否可以支持windows服务,正好有解决类似问题的经验,于是给作者提了一个PR,不过作者表示:

  1. 类似脚本打算放到专门的仓库中维护
  2. 那个专门仓库目前无人维护

那就是没法了,只能记在自己的小本子上了。

效果演示

Run frp as Windows service

  1. Download winsw(WinSW.NET2.exe means need .NET 2.0 runtime,and so on),Rename it to frpc-service.exe and frps-service.exe .
  2. Put frpc-service.xml and frpc-service.xml to same directory as frp*-service.exe .
  3. Default location of frp is C:\frp, you can edit the xml config file.

install service

1
2
3
4
# for frp client
frpc-service.exe install
# for frp server
frps-service.exe install

You will see frp service in windows service manager

uninstall service

1
2
3
4
# for frp client
frpc-service.exe uninstall
# for frp server
frps-service.exe uninstall

以Windows服务的方式运行frp

  1. 下载winsw(它有多个运行时版本,WinSW.NET2.exe 的意思是需要安装 .NET 2.0 ),然后将其分别重命名为两个文件: frpc-service.exefrps-service.exe .
  2. frpc-service.xmlfrpc-service.xml 放到 frp*-service.exe 相同的目录下.
  3. 默认的frp安装目录是 C:\frp, 你可以在xml配置文件中修改。

创建服务

1
2
3
4
# for frp client
frpc-service.exe install
# for frp server
frps-service.exe install

服务创建后你在Windows的服务管理器里面就能看见frp服务了

服务卸载

1
2
3
4
# for frp client
frpc-service.exe uninstall
# for frp server
frps-service.exe uninstall

脚本(scripts)

frps-service.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>frps</id>
<!-- Display name of the service -->
<name>frp server</name>
<!-- Service description -->
<description>Service for frp server</description>
<!-- frp install dir -->
<workingdirectory>C:\frp</workingdirectory>
<!-- frps.exe -->
<executable>C:\frp\frps.exe</executable>
<!-- args -->
<startarguments>-c frps.ini</startarguments>
</service>

frps-service.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>frpc</id>
<!-- Display name of the service -->
<name>frp client</name>
<!-- Service description -->
<description>Service for frp client</description>
<!-- frp install dir -->
<workingdirectory>C:\frp</workingdirectory>
<!-- frpc.exe -->
<executable>C:\frp\frpc.exe</executable>
<!-- args -->
<startarguments>-c frpc.ini</startarguments>
</service>

screenshot

frp install dir

service wrapper dir

install service

CATALOG
  1. 1. Run frp as Windows service
  2. 2. 以Windows服务的方式运行frp
  3. 3. 脚本(scripts)
    1. 3.1. frps-service.xml
    2. 3.2. frps-service.xml
  4. 4. screenshot