#sveltekit service crashing :(

215 messages · Page 1 of 1 (latest)

umbral mango
#

I just deployed my brand new project on Railway and it tried running the bun run start command repeatedly which kept failing with the following error:

TERM environment variable not set.
error: script "start" exited with code 1 (SIGHUP)

The service inevitably crashed.

spring ivyBOT
#

Project ID: 12b919b0-8ae8-4936-a695-591b96aa0d64

umbral mango
#

Perhaps this is because I don't have any adapter setup?

civic locust
#

definitely is, you would want to use the node adapter and hope it's compatible with bun, if it's not then you have to use nodejs

umbral mango
#

Switching to nodejs shouldn't be a problem

#

Will try adding the node adapter

umbral mango
#

Tried adding the node adapter. The issue persists.

#

I doubt this is because of bun since it works on my local machine

#

cc @civic locust

civic locust
#

term environment variable not set issue still?

umbral mango
#

yes

#

the logs look identical to before adding the adapter

civic locust
#

what is your start script

umbral mango
#

the default? I didn't alter anything on Railway

civic locust
#

what is it

umbral mango
#

checking

umbral mango
civic locust
#

not quite what I asked

#

the start script.. in the package.json

umbral mango
#

Ah!

#

bun run css && vite build && clear && vite preview

#

css being: bunx tailwindcss -i ./src/app.css -o ./dist/tailwind.css

civic locust
#

that's not a start script

#

or at least it shouldn't be yours

umbral mango
#
  "scripts": {
    "css": "bunx tailwindcss -i ./src/app.css -o ./dist/tailwind.css",
    "dev": "bun run css && vite dev",
    "build": "bun run css && vite build",
    "preview": "bun run css && vite preview",
    "start": "bun run css && vite build && clear && vite preview"
  },
#

what should it be then

civic locust
#

just start the node server

umbral mango
civic locust
#

haha I've seen the node adapter docs, have you lol

umbral mango
#

:(

civic locust
#

you already run css and build in your build script, why are you running them again?

umbral mango
#

right so bun run build && node build

civic locust
#

you already run build in your build script, why are you running it again?

umbral mango
#

OH

#

oh yeah

#

lol

#

it's 2 am here sorry

civic locust
#

and while node build might work, you should be more explicit and specify the full path to the JavaScript file that you want to run

umbral mango
#

I don't have any specific JS file to run?

civic locust
#

yes you do

umbral mango
#

I simply have these

civic locust
#

vite build makes one with the node adapter

umbral mango
#

ah, build/index.js

civic locust
#

node build/index.js would use node to run the server, I thought you wanted to use bun?

umbral mango
#

And you'd be right.

#

I'm looking for a bun equivalent rn lol

#

But yeah a more critical error would be: Error: Prince#execute: cannot resolve binary "prince" to a filesystem path

#

😔

#

headed to prince docs

#

or wait

#

is there a way to install prince to the project env in Railway?

#

like I did with SQLC back then

#

some TOML file

civic locust
#

well what is prince

umbral mango
#

it is a tool that compiles HTML -> PDF

#

among some other things

#

I've defined it in my flake.nix, but Railway doesn't refer that 😔

#

PrinceXML to be precise

civic locust
#

is it available as a nix package or an apt package?

umbral mango
#

nix package

#

likely both

#

oh wait it isn't available as a nix package

#

I wrote my own package for it

umbral mango
civic locust
#

is it an overlay?

umbral mango
#

no, I just wrote my own package for it

#

very tiny script:

{ autoPatchelfHook, fetchurl, fontconfig, glibc, stdenv }:

stdenv.mkDerivation rec {
  pname = "princexml";
  version = "15.1";
  src = fetchurl {
    url = "https://www.princexml.com/download/prince-${version}-linux-generic-x86_64.tar.gz";
    hash = "sha256-rm0GeKPa8iDXBhW52GNcja09Qb+aYUtvFaxZUFHEOTw=";
  };

  nativeBuildInputs = [ autoPatchelfHook ];

  buildInputs = [
    fontconfig
    glibc
  ];

  installPhase = ''
    ./install.sh $out
    ln -sf /var/lib/prince/license.dat $out/lib/prince/license/license.dat
  '';
}
umbral mango
civic locust
#

what's it named

umbral mango
#

checking

#

should be princexml

umbral mango
#

yeah I can't find it either

civic locust
umbral mango
#

On that note

#

did the team say anything about flake support?

#

would fix all my dependency issues

civic locust
#

they want to support it natively, its just a low priority because few people use it

umbral mango
#

:(

#

I see

#

Makes perfect sense from a business POV but still a bummer lol

civic locust
#

but if you can write nix packages, writing a nixpacks.toml file would be no issue

umbral mango
#

It's about understanding how the toml works

umbral mango
civic locust
#

if you can understand how nix packages work, you can understand nixpacks.toml

umbral mango
#

yes

#

BTW, can I not use bun run preview as my start script?

#

it expanding to bun run css && vite preview

civic locust
#

that starts a dev server

umbral mango
#

rip

civic locust
#

use bun to run the index.js file

umbral mango
#

because apparently there's a lot of pain happening

#

I will just switch to nodejs

civic locust
#

its for the better

umbral mango
#

indeed

umbral mango
#

invalid use of variables?
ERROR: failed to solve: process "/bin/bash -ol pipefail -c tar -zxvf ${pname}.tar.gz ${pname}" did not complete successfully: exit code: 2

civic locust
#

lets see the nixpacks.toml file

umbral mango
#

it likely won't work as it's the first draft

#

just wanted to see what breaks

#

huh

#

I didn't delete it

civic locust
#

you edited it

umbral mango
#
# https://nixpacks.com/docs/configuration/file

[variables]
    pname = 'princexml'
    version = '15.1'

[phases.setup]
  nixPkgs = ['...', 'corefonts', 'fontconfig', 'glibc']

[phases.princexml]
    dependsOn = ['setup'] # make sure this phase runs after the default 'setup' phase
    cmds = [
        'curl -fsSLo ${pname}.tar.gz "https://www.princexml.com/download/prince-${version}-linux-generic-x86_64.tar.gz"',
        'tar -zxvf ${pname}.tar.gz ${pname}',
        'chmod +x ${pname}'
    ]

[start]
    runImage = 'ubuntu:20.04'
    cmd = './${pname} 2>&1'
#

I don't see it on my screen

#

do you

civic locust
#

you just sent it again, so yes

umbral mango
umbral mango
civic locust
#

also whats with the runimage and cmd?

umbral mango
#

Oh, there is no princexml subfolder in the tar.gz

umbral mango
civic locust
#

delete the start phase

#

also in your princexml phase you may want to copy the resulting binary file into maybe /bin or /usr/bin

#

since your code prob expects it in path?

umbral mango
#

yeah so

umbral mango
#

where do I put it?

#

[phases.install]?

civic locust
#

run it in the same phase

umbral mango
#

Okay, and the path would just be /bin?

civic locust
#

no, the PATH would be a bunch of different locations

umbral mango
#

not the PATH for prince

#

the PATH for the binary file

#

wait

#

that's the same thing

umbral mango
#

or do I have to copy paste/

civic locust
#

you dont need to, its just an example?

umbral mango
#

I see

#

weird.

#

idt it threw a 404 before

#

I copy pasted that URL, replacing ${version} and it works no problem

#

wonder why Railway throws a 404

#

probably a substitution error

#

Oh I can't reference variables in other variables?

#

[variables]
    pname = 'princexml'
    version = '15.1'
    full_name = 'prince-${version}-linux-generic-x86_64'
#

I had done this

civic locust
#

no you cant

umbral mango
#

yeah

#

realised now

umbral mango
#

If the build failed, then I likely need to tell the lib where the binary is

#

where is it? 💀

civic locust
#

did you put the binary in /bin ?

umbral mango
#

updated toml:

# https://nixpacks.com/docs/configuration/file

[variables]
    pname = 'princexml'
    full_name = 'prince-15.1-linux-generic-x86_64'

[phases.setup]
  nixPkgs = ['...', 'corefonts', 'fontconfig', 'glibc']

[phases.princexml]
    dependsOn = ['setup']
    cmds = [
        'curl -fsSLo ${pname}.tar.gz "https://www.princexml.com/download/${full_name}.tar.gz"',
        'tar -zxvf ${pname}.tar.gz ${full_name}',
        'chmod +x ${full_name}/install.sh',
        './${full_name}/install.sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
    ]
civic locust
#

bruh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin?????

umbral mango
#

hehe

#

it can choose

civic locust
#

not how it works

umbral mango
#

that's valid bash, though

#

okay okay, so I do this? './${full_name}/install.sh /bin'

civic locust
#

does it even need a path

umbral mango
#

yes

civic locust
#

it can decide itself

umbral mango
#
base=$( dirname "$0" )

cd "$base" || exit 1```
#

this is a line inside install.sh

civic locust
umbral mango
civic locust
#

current dir

umbral mango
#

I see

umbral mango
#

yes

#

a long while back

umbral mango
#

also me

civic locust
#

🤨

umbral mango
#

what are you raising brows for

#

It's 3 AM, I'm not usually this stupid

#

okay now

#

I didn't pass a path

umbral mango
#

since I need to tell that to my application

#

it still doesn't find the binary at whatever the default is

civic locust
#

looks like /usr/local/bin and that should be in PATH

umbral mango
#

there is an option in node-prince (the npm lib) for setting the binary but that might break local builds unless I remove it locally and keep it in prod

civic locust
#

do you see the Installation complete. message in your build logs

umbral mango
#

so it is in /usr/local thonk

#

that's the prefix

#

so /usr/local/bin

#

hmm

civic locust
#

and that also should be in PATH, so the npm package should look in PATH automatically

umbral mango
#

here's what the docs for the package say:

Prince#binary(binary): Prince: set the path to the prince(1) binary. By default it is prince (in case PrinceXML was found globally installed at the Node API installation time) or the path to the prince binary of the locally installed PrinceXML distribution (in case PrinceXML was not found globally installed at the Node API installation time). This returns the Prince API for further method chaining.
#

there is also:

Prince#prefix(prefix): Prince: set the path to the PrinceXML installation. This by default is either empty (in case PrinceXML was found globally installed at the Node API installation time) or the path to the locally installed PrinceXML distribution (in case PrinceXML was not found globally installed at the Node API installation time). This returns the Prince API for further method chaining.
civic locust
#

it can download prince for you? why havent you used that?

umbral mango
#

there is nothing to use?

#

it doesn't specify anything I'm supposed to do to install prince automatically

civic locust
#

read their docs?

umbral mango
#

they don't have docs IIRC

civic locust
#

read the source code?

umbral mango
#

this readme is all they have

#

lol ok

civic locust
#

but how do you run the download

umbral mango
#

so likely the download is automatically done at "Node API installation time"?

#

I found nothing regarding this in my build logs

civic locust
#

so then are you trying to overwrite the location in your code?

umbral mango
#

yes, to wherever it was installed using ./install.sh

civic locust
#

the package should find it automatically since it installs it into a folder in PATH

umbral mango
#

but it doesn't

#

(╯°□°)╯︵ ┻━┻

civic locust
#

sounds like something is misconfigured

civic locust
#

then specify /bin as the install path

umbral mango
#

why so?

umbral mango
#

I wasn't asking why should I specify /bin in the install path

#

I was asking why /bin specifically

umbral mango