rapiz1 / rathole

A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok.
Apache License 2.0
8.8k stars 440 forks source link

windows service not support #356

Closed lordnic99 closed 2 months ago

lordnic99 commented 2 months ago

Describe the bug

I'm using nssm for running the rathole in background, I got this error. image

To Reproduce Steps to reproduce the behavior:

  1. Install rathole on the background with nssm
  2. Start the service with nssm start {SERVICE_NAME}, got the error like the picture.

Configuration Configuration used to reproduce the behavior: image

Logs

There is no log cause windows service not showing anything when get failed Environment:

fernvenue commented 2 months ago

You need to specify the client.toml to the argument part, not the path.

lordnic99 commented 2 months ago

You need to specify the client.toml to the argument part, not the path.

image image

I have updated to this, but still same result.

ZhiShengYuan commented 2 months ago

You need to specify the client.toml to the argument part, not the path.

image image

I have updated to this, but still same result.

Reading the NSSM manual sounds like a good step. It's always helpful to refer to the official documentation for detailed information. Additionally, reaching out to someone familiar with this software could provide valuable insights or tips. Let's explore both avenues to resolve this issue efficiently.

lordnic99 commented 2 months ago

Fixed by writing a C++ for calling rathole, instead of calling it directly from nssm.

#include <iostream>
#include <string>
#include <windows.h>

int main() {
  std::string command_line = "C:\\HoangVPN\\rathole.exe C:\\HoangVPN\\client.toml";

  STARTUPINFO si;
  memset(&si, 0, sizeof(si));
  si.cb = sizeof(si);

  PROCESS_INFORMATION pi;
  memset(&pi, 0, sizeof(pi));

  if (!CreateProcess(NULL, const_cast<char*>(command_line.c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
    std::cerr << "Error creating process: " << GetLastError() << std::endl;
    return 1;
  }

  WaitForSingleObject(pi.hProcess, INFINITE);

  CloseHandle(pi.hProcess);
  CloseHandle(pi.hThread);

  return 0;
}

image

fernvenue commented 2 months ago

As I said above, you actually just need:

You need to specify the client.toml to the argument part, not the path.

Like this:

image

Is that hard to understand? And just like @ZhiShengYuan said, try to read the documentation first, don't assume you found a bug or something.

lordnic99 commented 2 months ago

As I said above, you actually just need:

You need to specify the client.toml to the argument part, not the path.

Like this:

image

Is that hard to understand? And just like @ZhiShengYuan said, try to read the documentation first, don't assume you found a bug or something.

Thanks, it works like charm.