Gaurav Bhatt
Gaurav Bhatt

Reputation: 1

The ts-node-dev doesn't work while working with skaffold dev command

I am running into problem where I'm not being able to run node server using **skaffold dev ** command. the file structure is like this:file structure

the skaffold.yaml file is:

apiVersion: skaffold/v4beta1
kind: Config
metadata:
  name: Ticketing
manifests:
  rawYaml:
    - ./infra/k8s/*
build:
  local:
    push: false
  artifacts:
    - image: gauri65/auth
      context: auth
      docker:
        dockerfile: Dockerfile
      sync:
        manual:
          - src: "src/**/*.ts"
            dest: "."

the infra/k8s has two files:

auth-depl.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: auth-app
  template:
    metadata:
      labels:
        app: auth-app
    spec:
      containers:
        - name: auth-app
          image: gauri65/auth:latest
          ports:
            - containerPort: 4000
          resources:
            limits:
              memory: "128Mi"
              cpu: "0.2"

---
apiVersion: v1
kind: Service
metadata:
  name: auth-srv
spec:
  selector:
    app: auth-app
  ports:
    - port: 4000
      protocol: TCP
      targetPort: 4000

and the ingress file is:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  labels:
    name: ingress-srv
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  ingressClassName: nginx
  rules:
    - host: ticketing.dev
      http:
        paths:
          - pathType: ImplementationSpecific
            path: "/api/users/?(.*)"
            backend:
              service:
                name: auth-srv
                port:
                  number: 4000

the package.json file is:

{
  "name": "auth",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "ts-node-dev src/index.ts --poll",
    "build": "npx tsc ",
    "dev": "nodemon dist/index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/express": "^4.17.21",
    "@types/node": "^20.11.16",
    "express": "^4.18.2",
    "nodemon": "^3.0.3",
    "ts-node": "^10.9.2",
    "ts-node-dev": "^2.0.0",
    "typescript": "^3.9.7"
  }
}

and this is what I get as output when running skaffold dev . Also running the docker container works fine without skaffold but doesn't sync with file changes.

Starting deploy...
 - deployment.apps/auth-depl created
 - service/auth-srv created
 - ingress.networking.k8s.io/ingress-service created
Waiting for deployments to stabilize...
 - deployment/auth-depl is ready.
Deployments stabilized in 3.471 seconds
Listing files to watch...
 - gauri65/auth
Press Ctrl+C to exit
Watching for changes...
[auth-app] 
[auth-app] > [email protected] start
[auth-app] > ts-node-dev src/index.ts --poll
[auth-app]
[auth-app] [INFO] 15:26:00 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.2, typescript ver. 3.9.10)
[auth-app] npm ERR! path /app
[auth-app] npm ERR! command failed
[auth-app] npm ERR! signal SIGKILL
[auth-app] npm ERR! command sh -c ts-node-dev src/index.ts --poll
[auth-app]
[auth-app] npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-02-04T15_25_38_289Z-debug-0.log
[auth-app]
[auth-app] > [email protected] start
[auth-app] > ts-node-dev src/index.ts --poll
[auth-app]
[auth-app] [INFO] 15:27:29 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.2, typescript ver. 3.9.10)
[auth-app] npm ERR! path /app
[auth-app] npm ERR! command failed
[auth-app] npm ERR! signal SIGKILL
[auth-app] npm ERR! command sh -c ts-node-dev src/index.ts --poll
[auth-app] 
[auth-app] npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-02-04T15_27_24_405Z-debug-0.log
[auth-app] 
[auth-app] > [email protected] start
[auth-app] > ts-node-dev src/index.ts --poll
[auth-app] 
[auth-app] [INFO] 15:28:55 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.2, typescript ver. 3.9.10)

I expect the result to show that the server is starting instead of crashing.

Upvotes: 0

Views: 132

Answers (1)

Gaurav Bhatt
Gaurav Bhatt

Reputation: 1

ps: the issue has been fixed. The problem was with how much resources was allocated to the pods vs how much resource was required by the pod. The auth-depl was having this resource:

      resources:
        limits:
          memory: "128Mi"
          cpu: "0.2"

changing the cpu allocation and memory allocation allowed the node server to run with no hinders. the limit was updated as:

        resources:
        limits:
          memory: "1024Mi"
          cpu: "1.0"

Upvotes: 0

Related Questions