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

Alpine Linux support for print_browsersync_port_taken_error #1255

Open
colindensem opened this issue Sep 6, 2020 · 1 comment
Open

Alpine Linux support for print_browsersync_port_taken_error #1255

colindensem opened this issue Sep 6, 2020 · 1 comment
Labels
hacktoberfest Valid Issue for Hacktoberfest

Comments

@colindensem
Copy link

I was experimenting with lucky, within an alpine container. This is for use within vscode remote containers/dev cycle. The lucky dev falls over during browsersync phase, within the tasks/watch cycle.

Alpine ships with a slimmed down version of ps and lsof.

For ps the -p and command flags aren't supported, instead you need ps -o comm

I think I've got a fix for this, but there are two possible approaches.

  1. Alter the code to check for busybox os, run the alternative command (See below)
  2. Add docs to detail installing procps && lsof when using alpine for full ps support

Possibly need both for the following code to work. Or simplify and don't try to show a list of processes, just say the port is in use. You'd still need the lsof package updating.

Sudo code for option 1, still work in progress, first lines of crystal ;)

    private def browsersync_port_taken_command
      io = IO::Memory.new
      busybox_command = "ps -o comm `lsof -ti :#{BROWSERSYNC_PORT}`"
      non_busybox_command = "ps -p `lsof -ti :#{BROWSERSYNC_PORT}` -o command"
      is_busybox_os? ? busybox_command : non_busybox_command
    end

    private def is_busybox_os?
      io = IO::Memory.new
      Process.run("ls --help 2>&1 | grep BusyBox", output: io, error: STDERR, shell: true)
      !io.to_s.empty?
    end

Happy to produce a pr with some guidance as to direction/necessity.

Background, I was only exploring alpine in case I take it to production, for slimmer images. It works fine out of the box using a crystallang/crystal:0.35.1 image.
I've pushed an alpine branch on this repo.

@paulcsmith
Copy link
Member

I'm wondering if maybe we should instead add some way to skip this check as mentioned in #1274. What do you think? Is this check helpful, or do you need this for a CI/Docker container? If so maybe skipping is the best option.

cc @KCErb

jwoertink added a commit that referenced this issue May 31, 2021
@jwoertink jwoertink added the hacktoberfest Valid Issue for Hacktoberfest label Oct 1, 2021
@jwoertink jwoertink removed the hacktoberfest Valid Issue for Hacktoberfest label Nov 1, 2021
@jwoertink jwoertink added the hacktoberfest Valid Issue for Hacktoberfest label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Valid Issue for Hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants