luckyframework / luckyframework/lucky

Alpine Linux support for print_browsersync_port_taken_error

Open
#1,255 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

hacktoberfest
Dominant language
Crystal
Stars
2.7k
Forks
172
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/colindensem/lucky/blob/7c90587567b3ea224a2dc6fa02e80a528d7864d9/tasks/watch.cr#L78).

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](https://github.com/colindensem/luckyframework-sandbox/tree/alpine-support).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tasks/watch.cr at the linked line and reproduce the browsersync port-taken path in an Alpine container. Compare the existing ps and lsof invocation with Alpine's BusyBox limitations and determine whether command handling or installation guidance is appropriate; done means `lucky dev` reports the occupied port successfully on Alpine.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal, linux
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.