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

No handler accepted "/" #22

Closed
schell opened this issue Mar 31, 2014 · 18 comments
Closed

No handler accepted "/" #22

schell opened this issue Mar 31, 2014 · 18 comments

Comments

@schell
Copy link

schell commented Mar 31, 2014

I'm trying to make ekg accessible out in the open on a server using

forkServer anIpAddress aPort

when visiting that ip address on that port I get No handler accepted "/". Is this expected? If so, how do I use ekg remotely?

@schell
Copy link
Author

schell commented Mar 31, 2014

Also - I can get json from ekg on the server using the header "Accept: application/json".

@tibbe
Copy link
Owner

tibbe commented Apr 1, 2014

Just to clarify, if you do

curl http://<your ip>:<your port>/

you get No handler accepted "/"?

@schell
Copy link
Author

schell commented Apr 1, 2014

Yes, specifically it returns

<!DOCTYPE html>
<html>
<head>
<title>Not found</title>
</head>
<body>
<code>No handler accepted "/"</code>
</body></html>

@schell
Copy link
Author

schell commented Apr 1, 2014

I'm guessing the host in the request doesn't match the ip address? I'll do some logging and try to see whats' going on.

@tibbe
Copy link
Owner

tibbe commented Apr 1, 2014

That would be helpful. Thanks.

@tibbe
Copy link
Owner

tibbe commented Apr 8, 2014

How did you start the server? The server needs access to its data files. This should work automatically if you install ekg but if you build and run it in-tree you need to use:

cd ekg
ekg_datadir=. ./my/executable

@aycanirican
Copy link

Placing assets to proper place and defining ekg_datadir ekg solved my problem. Thank you @tibbe .

@tibbe tibbe closed this as completed May 2, 2014
@afiskon
Copy link

afiskon commented Jul 9, 2014

Same problem here (ekg 0.4). I have all-in-one executable, which is packed in deb package. I placed assets directory in /var/lib/myproject/assets/ and modified init script the following way:

sudo -u $USER ekg_datadir=/var/lib/$NAME/assets/ $DAEMON

But it didn't solve the problem. Maybe hdaemonize could cause this?

BTW, did you consider to embed all necessary files using Template Haskell?

@tibbe
Copy link
Owner

tibbe commented Jul 9, 2014

Can you try

sudo -u $USER echo /var/lib/$NAME/assets/ $DAEMON

to make sure that the path expands correctly?

Using TH brings a host of other issues (cross compilation not working, etc) and since people who ship software to other machines to run there eventually will need to figure out how to ship whole packages of files (i.e. executable plus various templates, data files, etc) anyway, I don't think it's worth it.

@aycanirican
Copy link

I agree, please don't use TH unless it is really needed.

@afiskon
Copy link

afiskon commented Jul 9, 2014

@tibbe sure:

aa@aa.load:~$ sudo service auditlog start
Starting Auditlog
/var/lib/auditlog/assets/ /usr/lib/auditlog/bin/auditlog
aa@aa.load:~$ ls -la /var/lib/auditlog/assets/
total 224
drwxr-xr-x 2 auditlog auditlog  4096 Jul  9 08:29 .
drwxr-xr-x 3 auditlog auditlog  4096 Jul  9 06:44 ..
-rw-r--r-- 1 auditlog auditlog 47523 Jul  9 06:44 bootstrap-1.4.0.min.css
-rw-r--r-- 1 auditlog auditlog   803 Jul  9 06:44 chart_line_add.png
-rw-r--r-- 1 auditlog auditlog   473 Jul  9 06:44 cross.png
-rw-r--r-- 1 auditlog auditlog  3647 Jul  9 06:44 index.html
-rw-r--r-- 1 auditlog auditlog 91668 Jul  9 06:44 jquery-1.6.4.min.js
-rw-r--r-- 1 auditlog auditlog 37554 Jul  9 06:44 jquery.flot.min.js
-rw-r--r-- 1 auditlog auditlog   571 Jul  9 06:44 monitor.css
-rw-r--r-- 1 auditlog auditlog 13071 Jul  9 06:44 monitor.js
aa@aa.load:~$ ls -la /usr/lib/auditlog/bin/auditlog
-rwxr-xr-x 1 auditlog auditlog 27076209 Jul  9 06:31 /usr/lib/auditlog/bin/auditlog

@tibbe
Copy link
Owner

tibbe commented Jul 9, 2014

@afiskon sorry for being unclear, I meant for you to try to see if the Bash expression containing the $NAME etc variables expanded correctly in the context of sudo (as per the above command I gave), not if the directory contents is correct.

@afiskon
Copy link

afiskon commented Jul 9, 2014

@tibbe yes, the line above:

/var/lib/auditlog/assets/ /usr/lib/auditlog/bin/auditlog

was an output of command you asked to execute. I just wanted to make it clear that paths are OK.

And this:

ekg_datadir=/var/lib/auditlog/assets/ /usr/lib/auditlog/bin/auditlo

is a result of:

sudo -u $USER echo ekg_datadir=/var/lib/$NAME/assets/ $DAEMON

@tibbe
Copy link
Owner

tibbe commented Jul 9, 2014

@afiskon Alright, so we know that things are getting invoked correctly.

Could you try to add a line that logs whether the data dir is readable/exists (using e.g. System.Directory.doesDirectoryExist) right after this line in ekg https://github.com/tibbe/ekg/blob/master/System/Remote/Snap.hs#L72. Do something like:

monitor store = do
    dataDir <- liftIO getDataDir
    dataDirExists <- doesDirectoryExist dataDir
    unless dataDirExists $
        hPutStrLn stderr $ "ERROR: Data directory " ++ dataDir ++ " doesn't exist. If your data files are in a non-standard directory, you might need to set ekg_datadir."
    -- ...

@ods94065
Copy link

Here's my story while running into this problem:

I'm using Stack to build a web app (including ekg) that I'm deploying inside a Docker container. In particular, I'm installing my app in a fresh container with no explicit Haskell dependencies (we'll see how that goes!). JSON API calls to EKG worked but HTML did not.

The problem was indeed that the directory of assets didn't exist in the runtime container, and ekg could not find it. This directory contains the files needed to provide the HTML interface, and Snap apparently raises this error when a file it's trying to serve can't be found (see snapframework/snap#102 ).

The problem Sean mentions in #48 bit me hard, since if his path to the assets directory was weird, mine using Stack/Docker is really weird. I don't know an easy way to magic these files into my Docker installation, so I cheated: I'm pinning the ekg version for now and copying the assets/ directory into my project.

One final note: You'll see that ekg appends </> assets to your data directory, so make sure you're not setting your data directory to the assets directory itself! I installed my stuff in /app/ekg-0.4.0.9/assets, and set ENV ekg_datadir=/app/ekg-0.4.0.9 in my Docker container. That was what did the trick.

@dysinger
Copy link

dysinger commented May 6, 2016

I just hit the same problem with stack and a docker-enabled project

@dysinger
Copy link

dysinger commented May 6, 2016

It might be better to use fileEmbed so that directories don't need to be found.

@lorenzo
Copy link

lorenzo commented Jan 13, 2017

In case anyone is looking for a solution, I have this script for building the image:

	docker pull
	stack build
	find ~/.stack -name "assets" -exec cp -a {} shared_folder \;
	stack image container --build

This works with the following stack.yaml configuration:

docker:
    enable: true
    repo: "fpco/stack-build"
    auto-pull: true
image:
  container:
    name: image-name
    base: fpco/stack-run
    add:
        shared_folder: /build_stuff

And when executed with this ENV var:

ekg_datadir=/build_stuff

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

7 participants