gpt4 book ai didi

amazon-web-services - CloudFormation - 在 EC2 实例上安装和配置 CloudWatch 代理

转载 作者:行者123 更新时间:2023-12-03 07:27:26 27 4
gpt4 key购买 nike

我有一个使用 LaunchTemplate 创建 ec2 实例的 CloudFormation 模板,但我想将 cloudwatch 代理添加到实例中,但我不知道出了什么问题。

我有2个configSet,但是cfn-init卡在“02_download_app”> “Command run_app”,这部分我从/运行一个jar文件。

这是/var/log/cfn-init-cmd.log的输出,我注意到在命令run_app之后,jar卡住了17:25,一段时间后 17:42 我连接到实例,杀死 jar 并重新启动,它成功地继续执行脚本,我认为错误是一些编码问题,但我不知道在哪里: jar ?在log4j配置文件中?等等

2020-06-23 17:25:20,679 main ERROR Console contains an invalid element or attribute "Encoding"

cfn-init-cmd.log

    configSets:
setup:
- "01_install_java"
- "02_download_app"
- "03_setupCfnHup"
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
updateEnvironment:
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"

我关注了这个template ,这是我的模板的一部分和 cfn-init 部分。

AWSTemplateFormatVersion: 2010-09-09
Description: >-
Cloudformation template.

Metadata:
Stack:
Value: 2
VersionDate:
Value: 30032020
Identifier:
Value: template-app-stack
Input:
Description: EC2 Instance Types, DB Instance Type and Engine
Output:
Description: Outputs ID of all deployed resources

AWS::CloudFormation::Interface:
Parameters:
#....... other omitted .......#
#....... other omitted .......#
Resources:
#....... other omitted .......#
#backend autoscaling#
rBackendFleet:
Type: AWS::AutoScaling::AutoScalingGroup
Condition: cIsProduction
Properties:
AutoScalingGroupName: !Join [ '-', [!Ref pApplicationName, 'asg', !Ref pApplicationEnvironment, 'backend'] ]
VPCZoneIdentifier: !Ref pBackendSubnets
MinSize: 1
MaxSize: 10
MetricsCollection:
- Granularity: 1Minute
DesiredCapacity: 1
HealthCheckGracePeriod: 300
TargetGroupARNs:
- !Ref rPrivateLoadBalancerTargetGroup
LaunchTemplate:
LaunchTemplateId: !Ref rBackendLaunchTemplate
Version: !GetAtt rBackendLaunchTemplate.LatestVersionNumber
rBackendLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Metadata:
AWS::CloudFormation::Init:
configSets:
setup:
- "01_install_java"
- "02_download_app"
- "03_setupCfnHup"
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
updateEnvironment:
- "04_config-amazon-cloudwatch-agent"
- "05_restart_amazon-cloudwatch-agent"
01_install_java:
packages:
apt:
unzip: []
openjdk-8-jre-headless: []
02_download_app:
files:
/tmp/backend.zip:
source: !Sub
- >-
https://${bucketName}.s3-${region}.amazonaws.com/${objectKey}
- bucketName: !Ref pSourceCodeBucketName
objectKey: !Ref pBackendArtifactObjectKey
region: !Ref AWS::Region
mode: "000644"
owner: "root"
group: "root"
authentication: rolebased
commands:
configure_app:
command: "sudo unzip backend.zip"
test: "sudo ls -la"
cwd: "/tmp"
run_app:
command: "sudo java -jar /tmp/app.jar &"
test: "sudo ps -ef | grep java"
cwd: "/"
04_config-amazon-cloudwatch-agent:
files:
/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json:
content: !Sub |
{
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
"ImageId": "${!aws:ImageId}",
"InstanceId": "${!aws:InstanceId}",
"InstanceType": "${!aws:InstanceType}"
},
"aggregation_dimensions":
[["AutoScalingGroupName"], ["InstanceId", "InstanceType"],[]]
,
"metrics_collected": {
"mem": {
"measurement": [
"mem_used_percent"
]
},
"swap": {
"measurement": [
"swap_used_percent"
]
}
}
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/profuturo/app/profuturo-rest-comunicaciones/logs/profuturo-rest-comunicaciones.log",
"log_group_name": "/var/log/${pApplicationName}-${pApplicationEnvironment}",
"log_stream_name": "{instance_id}",
"timestamp_format": "%Y-%m-%d %H:%M:%S,%f",
"multi_line_start_pattern": "{timestamp_format}"
}
]
}
}
}
}
05_restart_amazon-cloudwatch-agent:
commands:
01_stop_service:
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop"
02_start_service:
command: "/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s"
03_setupCfnHup:
files:
/etc/cfn/cfn-hup.conf:
content: !Sub |
[main]
stack=${AWS::StackName}
region=${AWS::Region}
verbose=true
interval=1
mode: "000400"
owner: "root"
group: "root"
/etc/cfn/hooks.d/amazon-cloudwatch-agent-auto-reloader.conf:
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.rBackendLaunchTemplate.Metadata.AWS::CloudFormation::Init.04_config-amazon-cloudwatch-agent
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource rBackendLaunchTemplate --configsets updateEnvironment --region ${AWS::Region}
runas=root
mode: "000400"
owner: "root"
group: "root"
/lib/systemd/system/cfn-hup.service:
content: !Sub |
[Unit]
Description=cfn-hup daemon
[Service]
Type=simple
ExecStart=/opt/aws/bin/cfn-hup
Restart=always
[Install]
WantedBy=multi-user.target
mode: "000400"
owner: "root"
group: "root"
commands:
01enable_cfn_hup:
command: "systemctl enable cfn-hup.service"
02start_cfn_hup:
command: "systemctl start cfn-hup.service"
AWS::CloudFormation::Authentication:
rolebased:
type: S3
buckets:
- !Sub ${pSourceCodeBucketName}
roleName:
Ref: pInstanceRole
Properties:
LaunchTemplateName: !Join [ '-', [!Ref pApplicationName, 'lt', !Ref pApplicationEnvironment, 'backend'] ]
LaunchTemplateData:
BlockDeviceMappings:
- Ebs:
VolumeSize: 10
VolumeType: gp2
DeviceName: /dev/sda1
SecurityGroupIds:
- !Ref rBackendSecurityGroup
EbsOptimized: false
IamInstanceProfile:
Arn: !GetAtt rRootInstanceProfile.Arn
ImageId: !Ref pBackendAMI
InstanceType: !Ref pBackendInstanceType
KeyName: !Ref pKeyName
Monitoring:
Enabled: true
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
sudo apt-get update -y
sudo apt-get install -y python
sudo apt-get install -y python-setuptools
sudo apt-get install -y python-pip
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb -O /tmp/amazon-cloudwatch-agent.deb
dpkg -i /tmp/amazon-cloudwatch-agent.deb
sudo mkdir -p /opt/aws/bin
sudo python /usr/lib/python2.7/dist-packages/easy_install.py --script-dir /opt/aws/bin https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
sudo /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource rBackendLaunchTemplate --configsets setup,updateEnvironment --region ${AWS::Region}
sudo /opt/aws/bin/cfn-signal -e $? -r "Backend setup done." --stack ${AWS::StackName} --resource rBackendLaunchTemplate --region ${AWS::Region}
........
#App Tier Autoscaling#
#....... other omitted .......#

我观看了/var/log/cloud-init-output.log,但没有任何错误线索,说这是一些编码问题,但在哪一步?

+ sudo /opt/aws/bin/cfn-init -v --stack cwp-prod --resource rBackendLaunchTemplate --configsets setup,updateEnvironment --region us-west-2
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 13224: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 13233: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 306: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 309: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 207: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 284: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 290: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 180: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 114: ordinal not in range(128)
Logged from file util.py, line 503
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 891, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 130: ordinal not in range(128)
Logged from file util.py, line 503
+ sudo /opt/aws/bin/cfn-signal -e 0 -r 'Backend setup done.' --stack cwp-prod --resource rBackendLaunchTemplate --region us-west-2
ValidationError: Stack arn:aws:cloudformation:us-west-2:496852590701:stack/cwp-prod/80743380-b533-11ea-9ea4-02e40fd26800 is in CREATE_COMPLETE state and cannot be signaled
Cloud-init v. 19.3-41-gc4735dd3-0ubuntu1~18.04.1 running 'modules:final' at Tue, 23 Jun 2020 20:31:35 +0000. Up 23.76 seconds.
2020-06-23 21:31:14,217 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]
2020-06-23 21:31:14,223 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2020-06-23 21:31:14,226 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
Cloud-init v. 19.3-41-gc4735dd3-0ubuntu1~18.04.1 finished at Tue, 23 Jun 2020 21:31:14 +0000. Datasource DataSourceEc2Local. Up 3602.81 seconds

最佳答案

我猜你指的是这个sudo java -jar/tmp/app.jar &?我认为你应该在 test 完成后在 Init 中杀死它。

实现此目的的一种方法如下:

run_app:
command: |
sudo java -jar /tmp/app.jar &
PROCESS_ID=$!
test: "sudo ps -ef | grep java"
cwd: "/"

run_app_kill:
command: "sudo kill -9 $PROCESS_ID"

我认为一般情况下也不需要sudo。由于您没有对步骤进行编号,因此必须确保 run_app_killrun_app 之后运行。

关于amazon-web-services - CloudFormation - 在 EC2 实例上安装和配置 CloudWatch 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62545259/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com