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

Consider support fswatch #17

Open
josevalim opened this issue May 29, 2015 · 23 comments
Open

Consider support fswatch #17

josevalim opened this issue May 29, 2015 · 23 comments
Assignees

Comments

@josevalim
Copy link
Contributor

fswatch supports unix, freebsd and mac, so it looks like a nice alternative. I am posting it here in case someone wants to tackle it: https://github.com/emcrisostomo/fswatch

@5HT
Copy link
Owner

5HT commented Jun 6, 2015

I will take a look closely after finishing my trip.
While it longs, I'm just saying Hello from Tibet :-)

@mrmarbury
Copy link

FreeBSD user here .. I would really like to have this, too :)

Cheers

@5HT
Copy link
Owner

5HT commented Sep 23, 2015

Oh hai!
I see https://github.com/Vagabond/erl_kqueue
Or there is better/smaller filesystem watching API ?

UPD. I added basic freebsd compilation and bsd running support but it should be finished.

@5HT
Copy link
Owner

5HT commented Sep 24, 2015

@josevalim I reviewed fswatch. I'd better support everything that users of elixir and erlang is using. I just don't want to throw away our backends. They are cute. From the other side fs won't rely on anything, we have freedom.

@gregstula
Copy link

+1

@kuon
Copy link

kuon commented Jun 15, 2016

I started developing on freebsd as well (phoenix) and no support for code reloading is a bit problematic. Any ETA on this fix? I can provide help with testing if needed.

@jj1bdx
Copy link

jj1bdx commented Jul 28, 2016

Found the following error in FreeBSD 11.0-BETA2 with Erlang/OTP 19.0.2 and Elixir 1.3.2 running Phoenix 1.2.0:

[error] fs does not support the current operating system

Is the error message above benign?
(I've been redirected to here from phoenixframework/phoenix#920 )

@polymetis
Copy link

@jj1bdx Yeah it is benign. There is at least a way to configure Brunch to use polling (add this to your brunch config)

watcher: {usePolling: true}

But can't really get the live channels update working without some lifting here.

@dch Do you think we can tackle this one?

@kuon
Copy link

kuon commented Oct 31, 2016

@jj1bdx basically you won't get live reload if you do development under FreeBSD for now. I have not been affected in production.

@proger
Copy link
Contributor

proger commented Nov 4, 2016

I've added rudimentary support for fswatch (it becoming the only backend) in erlfsmon. Take a look, perhaps the backend could be similarly used in fs (I haven't tested it anywhere but osx, it uses the sh -c '$0; read; kill' trick, so i'm not sure how this will work out on windows).

@kuon
Copy link

kuon commented Feb 15, 2017

@proger Any update on this issue? Maybe I can help if you give me some context? (I am a bit lost as to what exactly has to be done)

This is the only thing preventing me from developing on FreeBSD via SSH from windows.

@skull-squadron
Copy link

skull-squadron commented Apr 9, 2017

@kuon As a temporary fix, try to make the inotify support work using https://github.com/wulf7/libinotify-kqueue shim. fs might needs some patches to work.

To this issue: Making a proper kqueue/kevent backend is the best way to go. Less brittle at the expense of duplicating some effort. Ancedotal evidence: our team once had to rip out a fsevent file notification monitor backend in another language that communicated with an external process because it leaked those processes and wasted METRIC TONS of resources, slowing down development.

@kuon
Copy link

kuon commented Apr 9, 2017

@steakknife If we are going to throw in a dependency, I'd go for fswatch.

@skull-squadron
Copy link

@kuon Then feel free to implement it. Good luck!

@proger
Copy link
Contributor

proger commented Apr 9, 2017

Just in case, to simply use fswatch you need 25 LoC and erlsh:

https://github.com/proger/erlfsmon#the-core

@skull-squadron
Copy link

skull-squadron commented Apr 9, 2017

@proger fswatch is licensed under GPL 3. That's fine for most hobbyists and some local development, but it's unusable for anything real. watchman has a much better license, platform interop and larger community; 3rd-party bindings (untested).

@proger
Copy link
Contributor

proger commented Apr 9, 2017

@steakknife Great find! I was not aware of this tool. Fortunately, it's not a lot of work to add support for watchman ;)

@kuon
Copy link

kuon commented Apr 9, 2017

Watchman BSD support is not actively developed. See the note at the top: https://facebook.github.io/watchman/docs/install.html

@kuon
Copy link

kuon commented Apr 9, 2017

@steakknife We could add fswatch support without bundling it. And if it's not in the PATH, just print a message.

@skull-squadron
Copy link

@kuon If you need BSD watchman support, then feel free to volunteer. :)

@duke-m
Copy link
Contributor

duke-m commented Aug 8, 2017

what about degrading the message from [error] to [warning] in the meanwhile:
[warning] fs does not support the current operating system: automatic code reloading might not work
or similar?

duke-m added a commit to duke-m/fs that referenced this issue Aug 8, 2017
changed the missing-support message to be a warning. added more information. see 5HT#17
@duke-m duke-m mentioned this issue Aug 8, 2017
@duke-m
Copy link
Contributor

duke-m commented Aug 14, 2017

sorry for the not re- or pre-thought pull request.

https://github.com/duke-m/kqclient

can we try to use this as a base for the fs-bsd-port?

@duke-m
Copy link
Contributor

duke-m commented Aug 15, 2017

sys/kq.erl sketch:

known_events() -> [renamed, removed, modified, undefined].

start_port(Path, Cwd) ->
    Path1 = filename:absname(Path),
    Args = [Path1],
    erlang:open_port({spawn_executable, find_executable()},
        [stream, exit_status, {line, 16384}, {args, Args}, {cd, Cwd}]).

line_to_event(Line) ->
    {match, [Path, F]} = re:run(Line, re(), [{capture, all_but_first, list}]),
    Flag = [convert_flag(F)],
    {Path, Flag}.

convert_flag("WRITE") -> modified;
convert_flag("DELETE") -> removed;
convert_flag("RENAME") -> renamed;
convert_flag(_) -> undefined.

re() ->
    case get(kq_re) of
        undefined ->
            {ok, R} = re:compile("^(.*) ([A-Z]+) .* .*$", [unicode]),
            put(kq_re, R),
            R;
        V -> V
    end.

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

10 participants