AWSで作成したpythonファイルを本番環境にデプロイしたい
pythonファイルをawsのcodedeployを使用して本番環境にデプロイしようとしたところ下記のエラーが発生しました。
原因わかりますでしょうか?
※開発環境で正常に動いていることは確認済みです
※インストールの処理は正常終了しています
発生している問題・エラーメッセージ
# err1 The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems. # err2 LifecycleEvent - ApplicationStart Script - start.sh [stderr]/opt/codedeploy-agent/deployment-root/164b6c08-f8ea-44ec-80b9-e62859201b16/d-YVM243O56/deployment-archive/start.sh: line 1: python3: command not found
ファイル構成
. ├── README.md ├── __pycache__ │ ├── blockchain.cpython-38.pyc │ ├── utils.cpython-38.pyc │ └── wallet.cpython-38.pyc ├── appspec.yml ├── blockchain.py ├── blockchain_server.py ├── blockchain_server_5001.py ├── blockchain_server_5002.py ├── requirements.txt ├── samp ├── start.sh ├── templates │ └── index.html ├── utils.py ├── wallet.py ├── wallet_server.py └── wallet_server_8081.py
該当のソースコード
appspec.yml
version: 0.0 os: linux files: - source: / destination: / hooks: Install: - location: requirements.txt ApplicationStart: - location: start.sh timeout: 3600
start.sh
start.sh
1python3 blockchain_server.py
blockchain_server.py
blockchain_server.py
1#!/usr/bin/python 2 3from flask import Flask 4from flask import jsonify 5from flask import request 6 7import blockchain 8import wallet 9 10app = Flask(__name__) 11 12cache = {} 13def get_blockchain(): 14 cached_blockchain = cache.get('blockchain') 15 if not cached_blockchain: 16 miners_wallet = wallet.Wallet() 17 cache['blockchain'] = blockchain.BlockChain( 18 blockchain_address=miners_wallet.blockchain_address, 19 port=app.config['port']) 20 app.logger.warning({ 21 'private_key':miners_wallet.private_key, 22 'public_key':miners_wallet.public_key, 23 'blockchain_address':miners_wallet.blockchain_address 24 }) 25 return cache['blockchain'] 26 27@app.route('/chain', methods=['GET']) 28def get_chain(): 29 block_chain=get_blockchain() 30 response = { 31 'chain':block_chain.chain 32 } 33 return jsonify(response), 200 34 35@app.route('/transactions', methods=['GET', 'POST', 'PUT', 'DELETE']) 36def transaction(): 37 block_chain = get_blockchain() 38 if request.method == 'GET': 39 transactions = block_chain.transaction_pool 40 response = { 41 'transactions':transactions, 42 'length':len(transactions) 43 } 44 return jsonify(response), 200 45 46 if request.method == 'POST': 47 request_json = request.json 48 required = ( 49 'sender_blockchain_address', 50 'recipient_blockchain_address', 51 'sender_public_key', 52 'value', 53 'signature' 54 ) 55 if not all(k in request_json for k in required): 56 return jsonify({'message':'missing values'}), 400 57 58 is_created = block_chain.create_transaction( 59 request_json['sender_blockchain_address'], 60 request_json['recipient_blockchain_address'], 61 request_json['value'], 62 request_json['sender_public_key'], 63 request_json['signature'], 64 ) 65 if not is_created: 66 return jsonify({'message':'fail'}), 400 67 return jsonify({'message':'success'}), 201 68 69 if request.method == 'PUT': 70 request_json = request.json 71 required = ( 72 'sender_blockchain_address', 73 'recipient_blockchain_address', 74 'sender_public_key', 75 'value', 76 'signature' 77 ) 78 if not all(k in request_json for k in required): 79 return jsonify({'message':'missing values'}), 400 80 81 is_updated = block_chain.add_transaction( 82 request_json['sender_blockchain_address'], 83 request_json['recipient_blockchain_address'], 84 request_json['value'], 85 request_json['sender_public_key'], 86 request_json['signature'], 87 ) 88 if not is_updated: 89 return jsonify({'message':'fail'}), 400 90 return jsonify({'message':'success'}), 200 91 92 if request.method == 'DELETE': 93 block_chain.transaction_pool=[] 94 return jsonify({'message':'success'}), 200 95 96@app.route('/mine', methods=['GET']) 97def mine(): 98 block_chain=get_blockchain() 99 is_mined=block_chain.mining() 100 if is_mined: 101 return jsonify({'message':'success'}), 200 102 return jsonify({'message':'fail'}), 400 103 104@app.route('/mine/start', methods=['GET']) 105def start_mine(): 106 get_blockchain().start_mining() 107 return jsonify({'message':'success'}), 200 108 109@app.route('/consensus', methods=['PUT']) 110def consensus(): 111 block_chain=get_blockchain() 112 replaced=block_chain.resolve_conflicts() 113 return jsonify({'replaced':replaced}), 200 114 115@app.route('/amount', methods=['GET']) 116def get_total_amount(): 117 blockchain_address=request.args['blockchain_address'] 118 return jsonify({ 119 'amount':get_blockchain().calculate_total_amount(blockchain_address) 120 }), 200 121 122if __name__=='__main__': 123 from argparse import ArgumentParser 124 parser = ArgumentParser() 125 parser.add_argument('-p', '--port', default=5000, 126 type=int, help='port to listen on') 127 args = parser.parse_args() 128 port = args.port 129 130 app.config['port']=port 131 get_blockchain().run() 132 133 app.run(host='0.0.0.0', port=port, threaded=True, debug=True)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/09/10 10:24
2020/09/10 10:30