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

Please improve the experience with Linux #155

Open
tmaier opened this issue Apr 12, 2018 · 16 comments
Open

Please improve the experience with Linux #155

tmaier opened this issue Apr 12, 2018 · 16 comments

Comments

@tmaier
Copy link

tmaier commented Apr 12, 2018

Hi,

I am a Mac user and currently working with some guys who are using Ubuntu as their main Operating System. Also a good choice.

However, I really see now how painful setting up puma-dev on Linux is.

  1. They overlook within the "Install on Linux" that ".dev domain" and "Port 80/443 binding" are sub-chapters
  2. Why is it necessary to compile this on every system? https://github.com/puma/dev-tld-resolver Can you provide a ready-to-use package?
  3. Chapter "Port 80/443 binding" mentions actually four different ways to do this.
  4. It would be also great to have something like $ puma-dev doctor, which tells what works and what does not yet work

Would it be possible to improve the linux support a bit?

@mlarraz
Copy link
Contributor

mlarraz commented Jun 12, 2018

FYI we run puma-dev on both Ubuntu and Mac, and this is the process we use to bootstrap it on Xenial:

  1. Install dnsmasq: sudo apt-get install dnsmasq

  2. Put the following in /etc/dnsmasq.d/dev

local=/dev/
address=/dev/127.0.0.1
address=/dev/::1
  1. Install puma-dev: go get -u github.com/puma/puma-dev/cmd/puma-dev

  2. Let puma-dev listen on port 80: sudo setcap CAP\_NET\_BIND\_SERVICE=+eip $GOPATH/bin/puma-dev

  3. Install a systemd process. Create /lib/systemd/system/puma-dev.service and put in the following:

[Unit]
After=network.target

[Service]
User=$USER
ExecStart=$HOME/go/bin/puma-dev -sysbind
Restart=on-failure

[Install]
WantedBy=multi-user.target

(substitute the $USER and $HOME variables based on the name of the user you want to run under)

  1. Start puma-dev:
sudo systemctl daemon-reload
sudo systemctl enable puma-dev
sudo systemctl start puma-dev
  1. Once puma-dev has generated self-signed certs, install them globally and restart the process:
sudo cp ~/.puma-dev-ssl/*.pem /etc/ssl/certs/
sudo update-ca-certificates
sudo systemctl restart puma-dev

You should now have puma-dev always running in the background, listening to port 80 and 443, with functioning SSL.

@durrellchamorro
Copy link

Puma-dev is a pleasure to work with on my Mac, but unfortunately on my Ubuntu 18.04 machine I'll have to use ngrok to work with API's that require ssl until I figure out how to install the certs puma-dev generates. The steps outlined by @mlarraz were helpful. I was able to get the dev-tld resolver mentioned in the puma-dev README to work in place of dnsmasq. The instructions for installing the certs here were helpful, but even though it seems like they installed successfully, my browsers still complain about an unsafe connection.

@puma puma deleted a comment from gkatsanos Aug 3, 2019
@nateberkopec
Copy link
Member

Anything is possible, we just need pull requests to make it a reality. AFAICT none of the open PRs to the puma-dev projects solve any of these issues (though point me to them if they do).

@puma puma deleted a comment from gkatsanos Aug 3, 2019
@gkatsanos
Copy link

Why are my comments deleted?

@nateberkopec
Copy link
Member

Any comments that are not constructive or helpful will be deleted. If this thread becomes a magnet for them, it will be locked.

The other comments in this issue have already laid on an extremely helpful roadmap for improving Linux support. These all sound like great ideas.

@gkatsanos
Copy link

gkatsanos commented Aug 4, 2019

I tried following @mlarraz instructions, results:

g@g-on-linux:~/repos/mh-platform$ go get -v -u github.com/puma/puma-dev/cmd/puma-dev
....
build github.com/puma/puma-dev/cmd/puma-dev: cannot load golang.org/x/exp/inotify: cannot find module providing package golang.org/x/exp/inotify

Seems that inotify is obsolete / doesn't exist anymore: https://github.com/golang/exp/tree/master/inotify

is it possible to remove it from vendors and use fsnotify instead? (it's already there)

steverabino pushed a commit to steverabino/puma-dev that referenced this issue Nov 9, 2019
Mostly following advice on puma#155
@cmeans
Copy link

cmeans commented Feb 4, 2020

What if any, are the issues with a puma-dev deployment on Bionic?

@nonrational
Copy link
Member

@cmeans try it and let us know if you have any issues.

@gkatsanos did that error prevent you from continuing? I tried docker run -t -i golang:1.13 /bin/bash and was able to get to a running binary with:

root@e3b42c8f9fdb:/go# go get -u github.com/puma/puma-dev/cmd/puma-dev
package golang.org/x/exp/inotify: no Go files in /go/src/golang.org/x/exp/inotify

root@e3b42c8f9fdb:/go# cd src/github.com/puma/puma-dev/

root@e3b42c8f9fdb:/go/src/github.com/puma/puma-dev# make
go build ./cmd/puma-dev
...

root@e3b42c8f9fdb:/go/src/github.com/puma/puma-dev# ./puma-dev -V
Version: devel (go1.13.8)

@tusharbhutada-tudip
Copy link

Tried to follow the steps at: #155

but stuck on step:

go get -u github.com/puma/puma-dev/cmd/puma-dev

with the following error:

package golang.org/x/exp/inotify: no buildable Go source files in /home/lt-238/go/src/golang.org/x/exp/inotify

Any help is appreciated

@nonrational
Copy link
Member

@tusharbhutada-tudip some diagnostic information would be helpful. go version, distribution name and version, etc.

note that AFAIK no buildable Go source files is just a warning. do you get an error message when trying to run make?

@tusharbhutada-tudip
Copy link

tusharbhutada-tudip commented Apr 4, 2020

I tried with
docker run -t -i golang:1.13 /bin/bash
and now at step:
root@e3b42c8f9fdb:/go/src/github.com/puma/puma-dev# ./puma-dev -V
Version: devel (go1.13.8)

And sorry but I'm not sure what to do next. Can you please help? What should I do next to make puma-dev running on my ubuntu

@nonrational
Copy link
Member

@tusharbhutada-tudip you probably don't want to build and run puma-dev inside a docker container. that approach was just to demonstrate building from source on a known ubuntu system. I'll add a note to that

make install should build and install the puma-dev binary to $GOPATH/bin. Or, you can download a pre-built linux binary and drop it in /usr/local/bin or similar.

Puma-dev setup setup on linux is very manual at present. Once you have the binary on your PATH, follow the steps https://github.com/puma/puma-dev#linux-support to enable all the bells and whistles like DNS resolution and daemonization.

@flyinggrizzly
Copy link

flyinggrizzly commented Jul 24, 2020

Wondering if anyone has had any success daemonizing puma dev and having it bound to ports 80/443. I've tried a few changes to the systemd service file and none of them seem to have worked. I'm running 20.04.

I can run puma-dev on 80/443 manually by running it through authbind, so that at least is confirmed.

Service configs I've tried:

# Using setcap to allow puma-dev to bind itself to 80/443
[Unit]
After=network.target

[Service]
User=$USER
ExecStart=/path/to/puma-dev -sysbind
Restart=on-failure

[Install]
WantedBy=multi-user.target
# Explicitly binding 80 and 443
[Unit]
After=network.target

[Service]
User=$USER
ExecStart=/path/to/puma-dev -http-port 80 -https-port 443
Restart=on-failure

[Install]
WantedBy=multi-user.target
# Running the service through authbind
[Unit]
After=network.target

[Service]
User=$USER
ExecStart=/path/to/authbind puma-dev -http-port 80 -https-port 443
Restart=on-failure

[Install]
WantedBy=multi-user.target

In all of these cases, I've specified the actual path to puma-dev or authbind--I've just reinterpolated the placeholder for these examples.

Both the setcap and authbind strategies work when running puma-dev as a foreground process, but none of these service file configs are able to achieve the same thing.

It's not urgent, since all my work is done in a tmux config and it's pretty cheap to set some pane somewhere off in a dark corner to run puma-dev in the foreground, but it would be nice to have it spun up on boot.

@minimul
Copy link

minimul commented Jan 15, 2021

@flyinggrizzly I am on Ubuntu 20.10. Installed using setcap and with the downloaded puma-dev binary put into /usr/local/bin.

I was getting this error when doing a journalctl | rg puma-dev:

puma-dev.service: Failed to determine user credentials: No such file or directory
puma-dev.service: Failed at step USER spawning /usr/local/bin/puma-dev: No such file or directory

In the systemd service file, I simply hard coded the User=$USER to my actually username. Worked.

@kofronpi
Copy link

kofronpi commented Jan 29, 2021

Everything is outdated, it's a real pain to set up puma-dev on ubuntu 20.04 right now. This is as close as a guide I could find :https://medium.com/@abhinavshakya05/configure-puma-dev-in-ubuntu-e1b36b5d91ba
But it is not working.
After following the guide,
I run sudo authbind ./puma-dev -http-port 80 -https-port 443 from the go puma dev install folder
It fetches apps in /root/.puma-dev
But then I have this in the browser: Cannot GET /
Even if I set up symlink and proxy for webpacker properly in /root/.puma-dev. Maybe it shouldn't use the root folder at all, but I can't even get it to connect in the browser otherwise.

EDIT
I'm getting closer. Ditched the usage with authbind as root thanks to sudo setcap 'cap_net_bind_service=+ep' ./puma-dev
Now I have this error in the browser:

	bash: ligne 27 : exec: puma : non trouvé

(it means not found at line 27)

I suspect it's because of RVM / Bundler but even aliasing puma to bundle exec puma does not work

EDIT# 2 : fixed it by adding a .powrc file at the root of my project with:

if [ -f "$rvm_path/scripts/rvm" ]; then
  source "$rvm_path/scripts/rvm"
  rvm use .
fi

So follow these steps :

@vandercloak
Copy link

@kofronpi and @flyinggrizzly I was hitting the same issues with running in the background. I was able to get it working in ubuntu 20.04 on boot up with the following service config. Hope it helps!

[Unit]
After=network.target

[Service]
User=nick
ExecStart=/path/to/authbind /path/to/puma-dev -http-port 80 -https-port 443
Restart=on-failure

[Install]
WantedBy=multi-user.target

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

No branches or pull requests