Best way to start node js app

hi

how to avoid address already in use and force restart http when deploy ?

  • I create a new hook to start to start node server

but have issue on each push code, it deploy, but not restart correctly http server

Error: listen EADDRINUSE: address already in use :::8080
at Server.setupListenHandle [as _listen2] (net.js:1313:16)
at listenInCluster (net.js:1361:12)
at Server.listen (net.js:1447:7)
at Function.listen

and it will be perfect if it restart each time when http down ?

i try it without succes when use cleaver cloud

kill $(lsof -t -i:9090)
cd {{ projectPath }}/current/repo/ && npm start

return

kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

but with terminal it’s ok

Cleaver’s activation hook should automatically take care of restarting the service for you. Is that not working?

nop , that why i need to make a hook

node {{ projectPath }}/current/repo/server.js &

Hi @spham - I got your video with push-to-deploy possibly not firing a webhook; but, click-to-deploy looks like it did. It shouldn’t make a difference.

Is the project on a public repo that you wouldn’t mind sharing?

Hello @spham - thanks for bringing some of the node.js issues you were experiencing to our attention! We took a deep dive and found a couple bugs, one around web directory location and another with the yarn packages deployment hook not working as expected. We just pushed out some fixes (releases.cleaver.cloud).

I’m not able to reproduce the new deployment not activating - if you have more details on how to repro, that’d be appreciated.

BTW - you mentioned an update to make env variables easier to manage; we just pushed a big enhancement around that as well. :smiley:

1 Like

i m just wake up. and will try.
i m using npm install in 2 directories(main and /apps). so I dont get if yarn will resolve it.

a quick test and some feedback.

  • restart service not work now ( on push or on click)
    (other question is it restart auto when service is failed while running?)
  • env is ok. but for node project is not usefull. maybe should we can read package.json

it maybe missing log. so it difficult to understand what not work while test

my custom hooks seems not work since last update

cd {{ projectPath }}/current/ && npm install

or
npm install -C {{ projectPath }}/current/apps/restaurant-bot

but this work fine, with releasePath

npm install -C {{ releasePath }}/apps/restaurant-bot

Can you show us a list of all your hooks?

It could be that your npm is running in the last release folder and the latest release folder.

Try something like:

cd {{ releasePath }}
npm install