0
Posted on Thursday, August 30, 2018 by 醉·醉·鱼 and labeled under

罗列所有container的IP地址

docker ps -q | xargs -n 1 docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}} {{ .Name }}'

单独monitor某个contrainer的logs


docker ps -a | grep payments | sed 's/ .*//' | xargs docker logs -f
0
Posted on Tuesday, August 21, 2018 by 醉·醉·鱼 and labeled under , ,
DatabaseCleaner上面的example过时了。按照示例去做的话,会报错 unknown method 'before'。在github上找到了答案,还是比较简单的。


class ActiveSupport::TestCase
  include FactoryGirl::Syntax::Methods

  ActiveRecord::Migration.check_pending!
  DatabaseCleaner.strategy = :truncation
  DatabaseCleaner.logger = Rails.logger
  setup { DatabaseCleaner.start }
  teardown { DatabaseCleaner.clean }
end

配置完成以后,就可以在MYSQL去monitor query,看具体是如何操作数据库的。

mysql> SHOW VARIABLES LIKE "general_log%";

+------------------+----------------------------+
| Variable_name    | Value                      |
+------------------+----------------------------+
| general_log      | OFF                        |
| general_log_file | /var/run/mysqld/mysqld.log |
+------------------+----------------------------+

mysql> SET GLOBAL general_log = 'ON';

观察log

tail -f -n300 /var/run/mysqld/mysqld.log

最后,重置改动。

mysql> SET GLOBAL general_log = 'OFF';

  1. https://stackoverflow.com/questions/568564/how-can-i-view-live-mysql-queries
  2. https://github.com/metaskills/minitest-spec-rails/issues/44#issuecomment-244155657