Skip to content

Option for listening to unix socket #661

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

Merged
merged 2 commits into from
Oct 27, 2016
Merged

Option for listening to unix socket #661

merged 2 commits into from
Oct 27, 2016

Conversation

resure
Copy link
Contributor

@resure resure commented Oct 18, 2016

Please check if the PR fulfills these requirements

  • An example has been added or updated in examples/ (for features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

  • Feature

What is the current behavior?
#659

It's possible to pass socket path as port param but it won't correctly handle access rights (chmod) to socket and EADDRINUSE errors.

What is the new behavior?

New option --socket added. It overrides port if present and adds additional handling to listen:

  • If connection is successful, then it works like before
  • If connection is failing (with EADDRINUSE error) then socket file is already present. In this case, we're trying to connect to that socket file.
    • If connection is successful, then socket is already used by some other server and current instance of webpack-dev-server stops
    • If connection failed, then socket is not used by other processes and can be safely unlinked. After that, it starts listen() like usually.
  • After listen() successfully started, it sets socket chmod to 666 (read-write for everybody, it necessary since servers like nginx are usually launched from other users like www-data).

Does this PR introduce a breaking change?

  • No

@resure resure changed the title Option for listening to socket Option for listening to unix socket Oct 19, 2016
Copy link
Member

@SpaceK33z SpaceK33z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small changes here. After that it's good to go.

Start dev server in socket mode:

```shell
node ../../bin/webpack-dev-server.js --open --socket ./webpack.sock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove --open here since it opens the wrong URL in this case?

location /webpack/ {
proxy_pass http://unix:/home/happywebpackuser/apps/todo/webpack.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using tabs and spaces here.

@resure
Copy link
Contributor Author

resure commented Oct 25, 2016

Done, I've appended that changes to the last commit.

@SpaceK33z SpaceK33z merged commit 9b7a14e into webpack:master Oct 27, 2016
@SpaceK33z
Copy link
Member

Thanks!

@SpaceK33z SpaceK33z mentioned this pull request Oct 29, 2016
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

Successfully merging this pull request may close these issues.

2 participants