1

我有一个用于 Rails 应用程序的简单 Procfile:

web: rails server -p $PORT
worker: bundle exec rake jobs:work
mysql: /usr/local/bin/mysqld --log-error=/dev/stout

所有进程都正确启动,这很棒。但是,当我用 CTRL-C 停止 Foreman 时,mysqld 并没有停止。它一直在后台运行。

当工头停止时,如何使 mysqld 停止?

有没有另一种通过命令行启动mysql的方法,我不知道?

4

2 回答 2

4

经过一番谷歌搜索,我在这里找到了答案:

https://dba.stackexchange.com/a/53062/2566

mysql: /usr/local/bin/mysqld --gdb
于 2014-09-11T01:55:59.627 回答
0

在我的电脑上,停止 MySQL 大概需要 6 秒,但是 foreman 会SIGKILL在 5 之后自动发送一个,所以在运行foreman的时候,需要延长SIGKILL. 我用了 10 秒,YMMV。

foreman start -t 10

mysql.sh

trap 'brew services stop mysql' INT TERM

ps aux | grep -v grep | grep -i mysqld

if [ $? -eq 0 ]
then
  echo "MySQL is already running"
else
  echo "Starting MySQL"
  brew services start mysql
fi

# https://unix.stackexchange.com/a/42911
sleep 2147483647

档案

mysql: ./mysql.sh
于 2017-09-03T17:10:17.203 回答