shift-org / shift-docs

Shift2Bikes: website and calendar for shift and pedalpalooza
https://shift2bikes.org
Other
22 stars 17 forks source link

get node app.js "service-ified" to some degree, so it auto-restarts on crash within prod container #638

Open fool opened 8 months ago

fool commented 8 months ago

not sure what the best practice is. Need to make sure this setup (both first-run and subsequent restarts) respect settings per https://github.com/shift-org/shift-docs/issues/635

ionous commented 8 months ago

i think the most reliable route would be with a docker container. i only know how to do that with docker compose ( as per https://github.com/shift-org/shift-docs/blob/beta/docker-compose.yml )

  node:
    build: 
      context: . 
      dockerfile: node.docker
    restart: always

but docker will happily watch and reboot the process when needed.

alternatively, express ( which we use ) has some suggestions: https://expressjs.com/en/advanced/best-practice-performance.html#ensure-your-app-automatically-restarts forever seems simplest, the others have features for multiple systems, log rotation, remote control, ... we would just have to choose one and try.