0

We have a repeating problem where CodeDeploy just loses access. This problem is bugging me and out Amazon AWS reseller support team for a few months now. After fresh instance ec2 creation our deploy works fine. After few days 7-14 days (10-30 deploys) codeDeploy just throws an error. We already upgraded codeDeploy to the newest version.

The directory exists and has good privileges. We had this problem on rsync. then we stopped using rsync and we now have it on first script that does anything in directory which is application stop.

Disk space is ok, nothing more is on logs than those below. At some point the codedeploy just does not see anything and cannot do anything.

At the same time on the same ec2 other software deployments work fine, just the one has problems. This app is React js dashboard with nodejs server that stops and starts. Also, application works fine, all files are there but only new deployments does not work.

We were using before rsync to swap files in file to lower downtime and we thought that maybe this is causing some problems but it is happening regardless if we use rsync or deployment in place. It seems like CodeDeploy bug... Also manually executing all commands in CodeDeploy scripts work fine. Only CodeDeploy can't do that anymore on its own.

ApplicationStop script:

#!/bin/bash

#/usr/local/lib/npm/bin/pm2
export PATH="/usr/local/lib/npm/bin/:$PATH"
cd /home/koza/dashboard/ && npm run start:prod



2021-01-27 22:18:29 [stdout]### Rsync z temp do glownego ###
2021-01-27 22:18:29 [stderr]rsync: getcwd(): No such file or directory (2)
2021-01-27 22:18:29 [stderr]rsync error: errors selecting input/output files, dirs (code 3) at util.c(1185) [Receiver=3.1.2]
2021-01-27 22:18:29 [stdout]ownership of '/home/koza/dashboard' retained as koza:koza
2021-01-27 22:18:29 [stdout]### REMOVING UNNECESSARY FILES ###
2021-01-27 22:18:29 [stdout]### PURGING TEMPORARY DIR ###
2021-01-27 22:18:31 Script - aws/startApp.sh
2021-01-27 22:18:31 [stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-27 22:18:31 [stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-27 22:18:31 [stderr]internal/bootstrap/switches/does_own_process_state.js:128
2021-01-27 22:18:31 [stderr]  cachedCwd = rawMethods.cwd();
2021-01-27 22:18:31 [stderr]                         ^
2021-01-27 22:18:31 [stderr]
2021-01-27 22:18:31 [stderr]Error: ENOENT: no such file or directory, uv_cwd
2021-01-27 22:18:31 [stderr]    at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:128:26)
2021-01-27 22:18:31 [stderr]    at new API (/usr/local/lib/npm/lib/node_modules/pm2/lib/API.js:70:24)
2021-01-27 22:18:31 [stderr]    at Object.<anonymous> (/usr/local/lib/npm/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
2021-01-27 22:18:31 [stderr]    at Module._compile (internal/modules/cjs/loader.js:999:30)
2021-01-27 22:18:31 [stderr]    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
2021-01-27 22:18:31 [stderr]    at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-27 22:18:31 [stderr]    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-27 22:18:31 [stderr]    at Module.require (internal/modules/cjs/loader.js:887:19)
2021-01-27 22:18:31 [stderr]    at require (internal/modules/cjs/helpers.js:74:18)
2021-01-27 22:18:31 [stderr]    at Object.<anonymous> (/usr/local/lib/npm/lib/node_modules/pm2/bin/pm2:3:1) {
2021-01-27 22:18:31 [stderr]  errno: -2,
2021-01-27 22:18:31 [stderr]  code: 'ENOENT',
2021-01-27 22:18:31 [stderr]  syscall: 'uv_cwd'
2021-01-27 22:18:31 [stderr]}
2021-01-27 22:18:31 [stderr]chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-27 22:18:31 [stdout]
2021-01-27 22:18:31 [stdout]> koza-dashboard@3.0.0 start:prod /home/koza/dashboard
2021-01-27 22:18:31 [stdout]> pm2 start ecosystem.config.js --env production
2021-01-27 22:18:31 [stdout]
2021-01-27 22:18:32 [stdout][PM2][WARN] Environment [production] is not defined in process file
2021-01-27 22:18:32 [stdout][PM2] Applying action restartProcessId on app [sm-dashboard](ids: [ 0 ])
2021-01-27 22:18:32 [stdout][PM2] [sm-dashboard](0) ✓

2021-01-11 23:15:56 [stdout]### REMOVING UNNECESSARY FILES ###
2021-01-11 23:15:56 [stdout]### PURGING TEMPORARY DIR ###
2021-01-11 23:15:57 Script - aws/startApp.sh
2021-01-11 23:15:57 [stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-11 23:15:57 [stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-11 23:15:57 [stderr]chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

2021-01-12 15:31:54 [stdout]changed ownership of '/home/koza/temp_dashboard' from root:root to koza:koza
2021-01-12 15:31:54 [stderr]rsync: getcwd(): No such file or directory (2)
2021-01-12 15:31:54 [stderr]rsync error: errors selecting input/output files, dirs (code 3) at util.c(1185) [Receiver=3.1.2]
2021-01-12 15:31:54 [stdout]### Rsync z temp do glownego ###
2021-01-12 15:31:54 [stdout]ownership of '/home/koza/dashboard' retained as koza:koza
2021-01-12 15:31:54 [stdout]### REMOVING UNNECESSARY FILES ###
2021-01-12 15:31:54 [stdout]### PURGING TEMPORARY DIR ###
2021-01-12 15:31:54 Script - aws/startApp.sh
2021-01-12 15:31:54 [stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-12 15:31:54 [stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
2021-01-12 15:31:54 [stderr]/opt/codedeploy-agent/deployment-root/ccbab8f8-3a6a-4efd-8e71-753c33d93659/d-25VXE5DF8/deployment-archive/aws/startApp.sh: line 4: pm2: command not found
2021-01-12 15:31:54 [stderr]chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

LifecycleEvent - ApplicationStop
Script - aws/ApplicationStop.sh
[stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[stderr]internal/bootstrap/switches/does_own_process_state.js:128
[stderr] cachedCwd = rawMethods.cwd();
[stderr] ^
[stderr]
[stderr]Error: ENOENT: no such file or directory, uv_cwd
[stderr] at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:128:26)
[stderr] at new API (/usr/local/lib/npm/lib/node_modules/pm2/lib/API.js:70:24)
[stderr] at Object.<anonymous> (/usr/local/lib/npm/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
[stderr] at Module._compile (internal/modules/cjs/loader.js:999:30)
[stderr] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
[stderr] at Module.load (internal/modules/cjs/loader.js:863:32)
[stderr] at Function.Module._load (internal/modules/cjs/loader.js:708:14)
[stderr] at Module.require (internal/modules/cjs/loader.js:887:19)
[stderr] at require (internal/modules/cjs/helpers.js:74:18)
[stderr] at Object.<anonymous> (/usr/local/lib/npm/lib/node_modules/pm2/bin/pm2:3:1)

{ [stderr] errno: -2, [stderr] code: 'ENOENT', [stderr] syscall: 'uv_cwd' [stderr]}
CLOSED

LifecycleEvent - ApplicationStop
Script - aws/ApplicationStop.sh
[stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[stdout]/
[stderr]internal/bootstrap/switches/does_own_process_state.js:129
[stderr] cachedCwd = rawMethods.cwd();
[stderr] ^
[stderr]
[stderr]Error: ENOENT: no such file or directory, uv_cwd
[stderr] at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:129:28)
[stderr] at new API (/usr/local/lib/npm/lib/node_modules/pm2/lib/API.js:70:24)
[stderr] at Object.<anonymous> (/usr/local/lib/npm/lib/node_modules/pm2/lib/binaries/CLI.js:22:11)
[stderr] at Module._compile (internal/modules/cjs/loader.js:1063:30)
[stderr] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
[stderr] at Module.load (internal/modules/cjs/loader.js:928:32)
[stderr] at Function.Module._load (internal/modules/cjs/loader.js:769:14)
[stderr] at Module.require (internal/modules/cjs/loader.js:952:19)
[stderr] at require (internal/modules/cjs/helpers.js:88:18)
[stderr] at Object.<anonymous> (/usr/local/lib/npm/lib/node_modules/pm2/bin/pm2:3:1)

{ [stderr] errno: -2, [stderr] code: 'ENOENT', [stderr] syscall: 'uv_cwd' [stderr]}
silverangel
  • 57
  • 1
  • 6

1 Answers1

0

After some time trying to find an answer for this I decided to just go and restart the codedeploy-agent service.

Well it worked (on ubuntu):

sudo service codedeploy-agent restart
Caina Santos
  • 919
  • 1
  • 9
  • 16