Cannot run Ocsigen app: "Cannot create the command pipe ...lib/ocsigenserver/var/run/ocsigenserver_command"

Hi, I’m an OCaml beginner. Probably should stick with learning the fundamentals first. Anyway, I gave Ocsigen a try.

First install it (I’m on macOS Sequoia M2):

brew install ocsigenserver

OK, let’s create a project:

dune init project mysite

Then tweak the .dune file a bit:

(executable
 (public_name mysite)
 (name main)
 (libraries
  ocsigenserver
  ocsigenserver.ext.staticmod))

Let’s run it:

$ dune exec mysite
mysite: ocsigen:main: Cannot create the command pipe /Users/andretampubolon/.opam/5.2.0-flambda/lib/ocsigenserver/var/run/ocsigenserver_command. I will continue without.: Unix.Unix_error(Unix.ENOENT, "mkfifo", "/Users/andretampubolon/.opam/5.2.0-flambda/lib/ocsigenserver/var/run/ocsigenserver_command")

OK, what’s wrong here? For anyone curious, this is the entire repo

This might just be a warning ? If that’s the case, the app is running fine.

The “command pipe” is used to send commands to the running server, which is probably not useful for simple apps but unfortunately is not an option.
Here’s what works for me:

let _ =
  Ocsigen_server.start
    ~ports:[ (`All, 8080) ]
    ~command_pipe:"local/var/run/blibli-cmd" ~logdir:"local/var/log/blibli"
    ~datadir:"local/var/data/blibli" ~default_charset:(Some "utf-8")
    [
1 Like

After further inspection, I guess indeed the app ran fine.
Opening http://localhost:8080 on browser gave you “Error: Not Found”. Perhaps mis-configuration.?

Then I changed the a code a bit (inspired by this):

let _ =
  Ocsigen_server.start
    [ Ocsigen_server.host [Staticmod.run ~dir:"/Users/andretampubolon/blah/" ()]]

/Users/andretampubolon/blah/ only contains 2 text files. It still gives you “Error: Not Found”. Should it give you a directory listing, instead?

“Error: Not Found” is what I expect from Staticmod.run, so everything seems to work. You should be able to create a file named index.html in that directory.

Staticmod.run doesn’t seem to have an option to enable directory listing but it seems that you could perhaps add (Extendconfiguration.listdirs true); to the list passed to Ocsigen_server.host. I haven’t tested this.

1 Like

Regarding the command pipe error, one can avoid it by making sure the directory that’s supposed to contain the named pipe exists (that’s the origin of the error). So in this case it would have removed the message to run:

mkdir -p /Users/andretampubolon/.opam/5.2.0-flambda/lib/ocsigenserver/var/run/
1 Like

Actually listing directories isn’t supported (yet) by ocsigenserver but you could have a try at the PR for that. :slight_smile: