前提・実現したいこと
ここに質問の内容を詳しく書いてください。
Slackbotを複数(2個)動かすためにnode.jsのforeverコマンドを使ってシェルスクリプトから起動しています。これをHeroku上で行いたいと思っていますが、起動してくれません。
Herokuに上げない状態でのbashの起動は確認しています。
Herokuのログを見るとrun.py(Slackbotを起動させる為のファイル)をforever processing fileとして二回起動してくれているようですが、その後"State changed from up to crashed" "Process exited with status 0"といって終了してしまっているようです。
プロセスを終了させずに動かすにはどのような変更が必要でしょうか。
エラーメッセージ 2019-03-31T06:30:38.730668+00:00 heroku[pbot.1]: Starting process with command `bash start.sh` 2019-03-31T06:30:39.470529+00:00 heroku[pbot.1]: State changed from starting to up 2019-03-31T06:30:40.596091+00:00 app[pbot.1]: warn: --minUptime not set. Defaulting to: 1000ms 2019-03-31T06:30:40.597635+00:00 app[pbot.1]: warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms 2019-03-31T06:30:40.597948+00:00 app[pbot.1]: info: Forever processing file: run.py 2019-03-31T06:30:41.048846+00:00 app[pbot.1]: warn: --minUptime not set. Defaulting to: 1000ms 2019-03-31T06:30:41.050510+00:00 app[pbot.1]: warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms 2019-03-31T06:30:41.050986+00:00 app[pbot.1]: info: Forever processing file: run.py 2019-03-31T06:30:41.147878+00:00 heroku[pbot.1]: State changed from up to crashed 2019-03-31T06:30:41.121824+00:00 heroku[pbot.1]: Process exited with status 0
該当のソースコード
bash
1#!/bin/sh 2# ワークスペースの数だけAPIトークンを記載する 3tokens=($SLACKBOT_API_TOKEN1 $SLACKBOT_API_TOKEN2) 4 5for token in ${tokens[@]} 6do 7# トークンを書き換える 8export BOT_API_TOKEN=$token 9# Botを起動する 10./node_modules/.bin/forever start -c python3 run.py 11done
json
1{ 2 "name": "slackbot", 3 "version": "1.0.0", 4 "main": "index.js", 5 "scripts": { 6 "test": "echo \"Error: no test specified\" && exit 1" 7 }, 8 "keywords": [], 9 "author": "", 10 "license": "ISC", 11 "description": "", 12 "engine": { 13 "node": "v11.13.0", 14 "npm": "6.7.0" 15 }, 16 "dependencies": { 17 "forever": "*" 18 } 19}
Procfile
1pbot: bash start.sh
あなたの回答
tips
プレビュー