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

Implement communication with server via socket #9

Merged
merged 1 commit into from
Apr 22, 2016

Conversation

slashmili
Copy link
Contributor

Implement Server.IO and Server.Socket which each handles writing to
clients separately and move the logic of executing the commands to
Helpers.ProcessCommands. Refactor the commands to return the response as
string.

Also introduce options:
--listen runs Alchemist Server and listens to a random port
--no-ansi disable :iex colors
--env set the environment which loads the build file from

Starting the server

$ cd elixir_project
$ elixir path/to/alchemist-server/run.exs --env=dev --listen
ok|localhost:55580

Then the client connects and talk to the server like this:

$ nc localhost 55580
PING
PONG
END-OF-PING
COMP { "def", [ context: Elixir, imports: [Enum], aliases: [{MyList, List}] ] }
def
defexception/1
defoverridable/1
defstruct/1
def/2
defdelegate/2
defmacro/2
defmacrop/2
defmodule/2
defp/2
defprotocol/2
defimpl/3
END-OF-COMP

@msaraiva
Copy link

@slashmili I spent a couple of hours reviewing/testing your code. The only weird thing I've noticed while testing was that the number of processes kept increasing for every single request. After a very helpful :observer.start, I found this: https://github.com/slashmili/alchemist-server/blob/socket-server/lib/server/socket.exs#L41. Removing this line fixes the problem.

BTW, I really like this feature. AtomElixir will definitely use it. Thanks!

@slashmili
Copy link
Contributor Author

Thanks @msaraiva, that code was left over after refactoring APIs to return string. I'll make the change.

Great! BTW with this change alchemist always listen to localhost to a random port. Do you see yourself using it with binding to a specific ip/port?

Implement Server.IO and Server.Socket which each handles writing to
clients separately and move the logic of executing the commands to
Helpers.ProcessCommands. Refactor the commands to return the response as
string.

Also introduce options:
    --listen  runs Alchemist Server and listens to a random port
    --no-ansi disable :iex colors
    --env     set the environment which loads the build file from
@slashmili
Copy link
Contributor Author

@tonini I believe we are good to go!

@msaraiva
Copy link

@slashmili I think It would be nice to have a command line option to define the ip/port. This could be useful for people running elixir in a VM or container, like this. In those cases, the editor will not be able to start the server, which will be started manually, I guess. So if we had that option, we could save the values somehow and then reuse them even after a server restart. Anyway, it would be a nice feature but can be definitely done some other time. No need to rush on that.

@tonini
Copy link
Owner

tonini commented Apr 22, 2016

@slashmili Thanks a lot for all your patience :)

Thanks for the awesome contribution 👍 💚 💛 💙 ❤️

@tonini tonini merged commit b6d59a2 into tonini:master Apr 22, 2016
@slashmili slashmili deleted the socket-server branch April 22, 2016 07:12
@slashmili
Copy link
Contributor Author

Thanks!

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.

None yet

3 participants