Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to keep the server alive? #6

Open
solemone opened this issue Apr 26, 2022 · 3 comments
Open

Is there a way to keep the server alive? #6

solemone opened this issue Apr 26, 2022 · 3 comments

Comments

@solemone
Copy link

Hi @sindresorhus,

thanks for the package! We have one problem. Maybe you can help us.

The server seems the be paused from time to time. Is there an option or another way to keep the server alive until I close the terminal?

System: macOS 11.6, Node v14.17.3, npm 6.14.13

Every support is welcome!

@csouza1995
Copy link

I need a solution for the same problem, after few minutes the server closes without alert

@solemone or @sindresorhus found a method to solve it?

@Hannoma
Copy link

Hannoma commented Aug 24, 2023

I had a similar issue and after a lot of debugging finally got it working by clearing the stdout and stderr streams

start().then((server) => {
      // Clearing the buffer to prevent the server from hanging
      server.stdout.on('data', () => {})
      server.stderr.on('data', () => {})
    })

@frillsdev
Copy link

Thank you @Hannoma, you saved my sanity!

I needed to tweak your code slightly, but for the benefit of others, this is my whole php server file:

import phpServer from "php-server";

phpServer().then((server) => {
  server.stdout.on("data", () => {});
  server.stderr.on("data", () => {});
  console.log(`Project running at: ${server.url}`);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants