apex / up-examples

Example apps, apis, and sites for Up.
389 stars 42 forks source link

Broken crystal example #29

Open KELiON opened 7 years ago

KELiON commented 7 years ago

I just tried to test oss/crystal-basic example. PORT=3000 crystal main.cr works fine locally, up deployment works fine:

       build: 5 files, 3.2 MB (344ms)
       deploy: complete (17.647s)
        stack: complete (20.219s)

But opening result in browser shows:

{
  message: "Internal server error"
}

and in up logs I see:

  12:18:26pm INFO starting name: app-crystal type: server
  12:18:26pm INFO found free port 35452 version: $LATEST
  12:18:26pm INFO executing "./server" version: $LATEST
  12:18:26pm INFO waiting for http://127.0.0.1:35452 version: $LATEST
  12:18:26pm ERRO sh: ./server: No such file or directory
lukeed commented 7 years ago

This is because main.cr will compile to main by default. Similarly, up start is looking for a server file or directory.

You can change the output name while building crystal:

crystal build --release main.cr -o server
tj commented 7 years ago

hmm sounds like the Docker build failed. It works on my machine but I already have the tjholowaychuk/up-crystal image pulled. Maybe double check with up -v to see verbose output. up run build can be useful there too

For reference what it executes is:

$ docker run --rm -v $(PWD):/src -w /src tjholowaychuk/up-crystal crystal build --link-flags -static -o server main.cr
KELiON commented 7 years ago

Output of up -v:


     4ms     DEBU region defaulted to "us-west-2"
     0s      DEBU track "Deploy" map[regions:[us-west-2] stage:development header_rules_count:0 redirect_rules_count:0 inject_rules_count:0 has_cors:false has_logs:true duration:0s type:server os:darwin arch:amd64 version:0.1.6]
     0s      DEBU event deploy map[]
     0s      DEBU event platform.build map[]
     0s      DEBU hook build is not defined
     118ms   DEBU injecting proxy
     0s      DEBU open
     5ms     DEBU add _proxy.js: size=931 mode=-rwxr-xr-x
     0s      DEBU add byline.js: size=4710 mode=-rwxr-xr-x
     189ms   DEBU add main: size=8891243 mode=-rwxr-xr-x
     1ms     DEBU add main.rc: size=200 mode=-rw-r--r--
     0s      DEBU add up.json: size=28 mode=-rw-r--r--
     0s      DEBU stats dirs_filtered=0 files_added=5 files_filtered=0 size_uncompressed=8.9 MB
     6ms     DEBU close
     0s      DEBU event platform.build.zip map[files:5 size_uncompressed:8897112 size_compressed:3216991 duration:318.765499ms]
     1ms     DEBU removing proxy
     0s      DEBU event platform.build.complete map[duration:319.87964ms]
     589ms   DEBU checking for role
     0s      DEBU using existing role arn:aws:iam::953067738496:role/app-crystal-api-function
     0s      DEBU event platform.deploy map[stage:development region:us-west-2]
     4.949s  DEBU fetching function config region=us-west-2
     0s      DEBU event platform.function.update map[region:us-west-2 stage:development]
     0s      DEBU event platform.deploy.complete map[stage:development region:us-west-2 duration:4.949122068s]
     0s      DEBU hook clean is not defined
   ⠇ 0s
 DEBU event deploy.complete map[duration:5.857958144s]%

Output of up run build -v:

     3ms     DEBU region defaulted to "us-west-2"
   ⠋ 0s      DEBU track "Hook" map[name:build os:darwin arch:amd64 version:0.1.6]
     0s      DEBU track "Hook" map[name:build os:darwin arch:amd64 version:0.1.6]
   ⠋ 0s      DEBU hook build is not defined%

So, looks like problem is in up buildhook build is not defined. For me it is unexpected behaviour – up should fail in this case, no?

tj commented 7 years ago

hmm strange yeah it should infer from main.cr that it's a Crystal project. I'll see if I can reproduce, worth trying one of the newer releases as well.