0

我们有一个重复的问题,即 CodeDeploy 只是失去访问权限。这个问题困扰着我和亚马逊 AWS 经销商支持团队几个月了。创建新实例 ec2 后,我们的部署工作正常。几天后 7-14 天(10-30 次部署)codeDeploy 只是抛出一个错误。我们已经将 codeDeploy 升级到了最新版本。

该目录存在并具有良好的权限。我们在 rsync 上遇到了这个问题。然后我们停止使用 rsync,现在我们将它放在第一个脚本上,该脚本在应用程序停止的目录中执行任何操作。

磁盘空间还可以,日志中仅包含以下内容。在某些时候,codedeploy 什么都看不到,也不能做任何事情。

同时在同一个 ec2 上,其他软件部署工作正常,只是一个有问题。这个应用程序是带有停止和启动的 nodejs 服务器的 React js 仪表板。此外,应用程序工作正常,所有文件都在那里,但只有新部署不起作用。

我们之前使用 rsync 来交换文件中的文件以减少停机时间,我们认为这可能会导致一些问题,但无论我们使用 rsync 还是就地部署,它都会发生。看起来像 CodeDeploy 错误...手动执行 CodeDeploy 脚本中的所有命令也可以正常工作。只有 CodeDeploy 自己不​​能再这样做了。

ApplicationStop 脚本:

#!/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]}
4

1 回答 1

0

经过一段时间试图找到答案后,我决定去重新启动codedeploy-agent服务。

它工作得很好(在ubuntu上):

sudo service codedeploy-agent restart
于 2022-02-16T21:40:45.610 回答