Nodemon takes a while to pick up nfs changes

8/11/2018

This may be configurable in the nfs share or within nodemon, not sure...

Basically, for local dev of production k8s system using minikube with a persistent volume claim where the volume is a locally defined nfs share.

/etc/exports:

/path/to/nfs/share -alldirs -mapall=501:20 192.168.99.100

volume.yml:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-volume
spec:
  capacity:
    storage: 15Gi
  accessModes:
  - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: standard
  nfs:
    server: 192.168.99.1
    path: /path/to/nfs/share
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: cr-volume
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 15Gi

deployment.yml:

...(relevant section to mounting nfs share into container)
containers:
        - name: user
          image: image_name
          imagePullPolicy: Always
          command:
          - npm
          args:
          - run
          - dev-start
          ports:
          - containerPort: 5600
          - containerPort: 5898
          volumeMounts:   # mount host directory for local development
            - mountPath: /usr/src/app
              name: user-mount
              subPath: backend/services/user
      volumes:
        - name: user-mount
          persistentVolumeClaim:
            claimName: cr-volume
...

The command here (npm run dev-start) is . ./config/development/export-env.sh && DEBUG=user:* node_modules/nodemon/bin/nodemon.js --inspect=0.0.0.0:5898 --legacy-watch -L ./bin/www as opposed to the prod npm start of node ./bin/www

So this all works and mimics a prod env locally and allows me to make changes on the local file system which make their way through to the containers and reload. My only issue is that nodemon generally won't pick up the changes to the file for between 30 to 60 seconds.

I don't know enough about nfs shares and how the daemon broadcasts changes or how nodemon with it's legacy-watch flag watches to know where to go from here, but I'd love to be able to fix this so changes are reloaded faster.

-- Robin Southgate
kubernetes
minikube
nfs
nodemon

0 Answers