winsw-frpc-service.jpg
winsw-frpc-service.jpg

About:

WinSW is a util­ity that al­lows you to wrap and man­age a Win­dows ser­vice for any ex­e­cutable.

frpc is a client for the frp (Fast Re­verse Proxy) tool, which en­ables you to ex­pose lo­cal servers to the in­ter­net.


Procedure:

To set up frpc as a Win­dows ser­vice us­ing WinSW, fol­low these steps:

  1. Download WinSW
  • Download the latest release of WinSW from the releases page. Choose the appropriate executable for your system, either WinSW-x64.exe or WinSW-x86.exe.
  1. Rename WinSW executable
  • Rename the downloaded WinSW executable to frpc-winsw.exe. This will be the service wrapper for the frpc executable.
  1. Create a configuration file
  • Create a new XML configuration file named frpc-winsw.xml in the same directory as the frpc-winsw.exe. Add the following content to the file:
<service>
  <id>frpc</id>
  <name>frpc</name>
  <description>frp client service managed by WinSW</description>
  <executable>path\to\frpc.exe</executable>
  <arguments>-c path\to\frpc.ini</arguments>
  <log mode="roll-by-size">
    <sizeThreshold>10485760</sizeThreshold>
    <keepFiles>3</keepFiles>
  </log>
  <onfailure action="restart" />
  <startmode>Automatic</startmode>
</service>
  • Replace path\to\frpc.exe with the actual path to your frpc.exe file.
  • Replace path\to\frpc.ini with the actual path to your frpc.ini configuration file.

2023-05-30_tree.png
2023-05-30_tree.png

  1. Install the service
  • Open a command prompt or PowerShell window with administrator privileges. Navigate to the directory containing frpc-winsw.exe and frpc-winsw.xml.
  • Run the following command to install the service:
.\frpc-winsw.exe install
In­stalling ser­vice 'frpc (frpc)'...
Ser­vice 'frpc (frpc)' was in­stalled suc­cess­fully.
  1. Start the service
  • After installing the service, start it by running the following command:
.\frpc-winsw.exe start
Ser­vice 'frpc (frpc)' was re­freshed suc­cess­fully.

Start­ing ser­vice 'frpc (frpc)'...
Ser­vice 'frpc (frpc)' started suc­cess­fully.


Also, we can restart a Win­dows ser­vice from the com­mand line (al­ter­na­tive)

net stop frpc
The frpc ser­vice is stop­ping.
The frpc ser­vice was stopped suc­cess­fully.
net start frpc
The frpc ser­vice is start­ing.
The frpc ser­vice was started suc­cess­fully.

2023-05-30_092634.png
2023-05-30_092634.png


Conclusion:

frpc is set up as a Win­dows ser­vice and will au­to­mat­i­cally start on sys­tem boot. You can man­age the ser­vice us­ing the Services man­age­ment con­sole or by us­ing the frpc-winsw.exe com­mands, such as stop, restart, and uninstall.


Reference: