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

Socket activation #1442

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Socket activation #1442

wants to merge 2 commits into from

Conversation

PhilipRoman
Copy link
Collaborator

@PhilipRoman PhilipRoman commented Nov 14, 2024

Add support for socket activation

Description

Added new constructor to WebSocketServer which takes an already prepared Channel.
If this constructor is used, then WebSocketServer will not try to open it's own channel, or bind it since it is expected to be handled by user.
This allows to use System.inheritedChannel() together with systemd socket activation, which passes the prepared socket as file descriptor #0.
Also added an example "smart" chat server, which will be brought up and down on-demand by systemd.
I have tested it and it is working as expected.
TODO: a unit test should be added which creates server with an existing Channel.
I am also considering adding a script for running an integration test in a container, to make sure socket activation works as expected with this feature.

Related Issue

Fixes #1440

Motivation and Context

Allows to use socket activation with websockets

How Has This Been Tested?

I ran the new example which is in src/main/example as a systemd unit. Server comes up and down as expected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

See #1440
The main motivation for this feature is the ability to integrate with
on-demand socket activation.
@Cu3PO42
Copy link

Cu3PO42 commented Nov 17, 2024

Thanks so much for working on this! I was able to use this branch to successfully implement support for inherited sockets in Robocode Tank Royale, as I described in #1440. See robocode-dev/tank-royale#115 for my PR there.

@marci4
Copy link
Collaborator

marci4 commented Nov 17, 2024

@PhilipRoman feel free to ping me when you are done

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

Successfully merging this pull request may close these issues.

Support for inherited sockets
3 participants