Redmineインストール練習
今更ながらRedmineを使うことになったので、手元で弄れる環境を作ってみた。というかそもそもRailsわかってない。
- Rubyのバージョン確認
(root)MacBook-Air-2:redmine foo$ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
- MySQLのバージョン確認
(root)MacBook-Air-2:redmine foo$ mysql --version mysql Ver 14.14 Distrib 5.7.16, for osx10.10 (x86_64) using EditLine wrapper
- MySQLのrootユーザのパスワードを忘れたので再設定
(root)MacBook-Air-2:redmine foo$ mysql.server stop Shutting down MySQL .. SUCCESS! (root)MacBook-Air-2:redmine foo$ mysqld_safe --skip-grant-tables & [1] 25012 (root)MacBook-Air-2:redmine foo$ 2016-01-01T11:13:30.6NZ mysqld_safe Logging to '/usr/local/var/mysql/MacBook-Air-2.local.err'. 2016-01-01T11:13:30.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql (root)MacBook-Air-2:redmine foo$ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.16 Homebrew Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> UPDATE user SET authentication_string=password('root') WHERE user='root'; Query OK, 1 row affected, 1 warning (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
- Redmine用のデータベース用意
(root)MacBook-Air-2:redmine foo$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.16 Homebrew Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database redmine character set utf8; Query OK, 1 row affected (0.01 sec) mysql> create user 'redmine'@'localhost' identified by 'my_password'; Query OK, 0 rows affected (0.02 sec) mysql> grant all privileges on redmine.* to 'redmine'@'localhost'; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
- Redmineのソース取得 (gitから取ってくればよかった、、、。)
(root)MacBook-Air-2:redmine foo$ svn checkout http://svn.redmine.org/redmine/branches/3.3-stable redmine A redmine/test A redmine/test/unit A redmine/test/unit/document_test.rb A redmine/test/unit/issue_import_test.rb A redmine/test/unit/repository_git_test.rb A redmine/test/unit/version_test.rb A redmine/test/unit/project_members_inheritance_test.rb A redmine/test/unit/attachment_transaction_test.rb 途中省略 A redmine/public/stylesheets/rtl.css A redmine/public/stylesheets/scm.css A redmine/public/stylesheets/application.css A redmine/public/favicon.ico A redmine/public/htaccess.fcgi.example U redmine Checked out revision 16052.
- Redmineアプリケーションフォルダに移動
(root)MacBook-Air-2:redmine foo$ cd redmine/ (root)MacBook-Air-2:redmine foo$ ls CONTRIBUTING.md README.rdoc app bin config.ru doc files log public test vendor Gemfile Rakefile appveyor.yml config db extra lib plugins script tmp
- データベースファイルを作成
(root)MacBook-Air-2:redmine foo$ vim ./config/ additional_environment.rb.example configuration.yml.example environments/ routes.rb application.rb database.yml.example initializers/ settings.yml boot.rb environment.rb locales/ (root)MacBook-Air-2:redmine foo$ cp ./config/database.yml.example ./config/database.yml
- データベース設定に、データベース名、ユーザ名、パスワードを設定する
1 # Default setup is given for MySQL with ruby1.9. 2 # Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end. 3 # Line indentation must be 2 spaces (no tabs). 4 5 production: 6 adapter: mysql2 7 database: redmine 8 host: localhost 9 username: redmine 10 password: my_password 11 encoding: utf8 12 13 development: 14 adapter: mysql2 15 database: redmine_development 16 host: localhost 17 username: redmine 18 password: my_password 19 encoding: utf8 20 21 # Warning: The database defined as "test" will be erased and 22 # re-generated from your development database when you run "rake". 23 # Do not set this db to the same as development or production. 24 test: 25 adapter: mysql2 26 database: redmine_test 27 host: localhost 28 username: my_password 29 password: my_password 30 encoding: utf8
- bundlerをインストール (意味がわかってない、後で調べる)
(root)MacBook-Air-2:redmine foo$ gem install bundler Fetching: bundler-1.13.6.gem (100%) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. (root)MacBook-Air-2:redmine foo$ sudo gem install bundler Password: Fetching: bundler-1.13.6.gem (100%) Successfully installed bundler-1.13.6 Parsing documentation for bundler-1.13.6 Installing ri documentation for bundler-1.13.6 1 gem installed
(root)MacBook-Air-2:redmine foo$ bundle install --without development test rmagick Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Resolving dependencies..... Rubygems 2.0.14 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation. Using rake 12.0.0 Using i18n 0.7.0 Using json 1.8.3 Using minitest 5.10.1 Using thread_safe 0.3.5 Using builder 3.2.2 Using erubis 2.7.0 Using mini_portile2 2.1.0 Using rack 1.6.5 Using mime-types-data 3.2016.0521 Using arel 6.0.3 Using public_suffix 2.0.4 Using bundler 1.13.6 Using coderay 1.1.1 Using concurrent-ruby 1.0.2 Using htmlentities 4.3.1 Using thor 0.19.4 Using mimemagic 0.3.2 Using mysql2 0.3.21 Using net-ldap 0.12.1 Using ruby-openid 2.3.0 Using rbpdf-font 1.19.0 Using redcarpet 3.3.4 Using request_store 1.0.5 Using tzinfo 1.2.2 Using nokogiri 1.6.8.1 Using rack-test 0.6.3 Using mime-types 3.1 Using addressable 2.5.0 Using sprockets 3.7.0 Using rack-openid 1.4.2 Using rbpdf 1.19.0 Installing activesupport 4.2.7.1 Installing loofah 2.0.3 Installing mail 2.6.4 Installing css_parser 1.4.7 Installing rails-deprecated_sanitizer 1.0.3 Installing globalid 0.3.7 Installing activemodel 4.2.7.1 Installing rails-html-sanitizer 1.0.3 Installing roadie 3.2.0 Installing rails-dom-testing 1.0.7 Installing activejob 4.2.7.1 Installing activerecord 4.2.7.1 Installing protected_attributes 1.1.3 Installing actionview 4.2.7.1 Installing actionpack 4.2.7.1 Installing actionmailer 4.2.7.1 Installing actionpack-action_caching 1.1.1 Installing actionpack-xml_parser 1.0.2 Installing railties 4.2.7.1 Installing sprockets-rails 3.2.0 Installing jquery-rails 3.1.4 Installing roadie-rails 1.1.1 Installing rails 4.2.7.1 Bundle complete! 31 Gemfile dependencies, 55 gems now installed. Gems in the groups development, test and rmagick were not installed. Use `bundle show [gemname]` to see where a bundled gem is installed.
- セキュリティトークン作成 (意味がわかってないので後で調べる)
(root)MacBook-Air-2:redmine foo$ bundle exec rake generate_secret_token
- データベーススキーマ作成
(root)MacBook-Air-2:redmine foo$ RAILS_ENV=production bundle exec rake db:migrate == 1 Setup: migrating ========================================================= -- create_table("attachments", {:force=>true}) -> 0.0133s -- create_table("auth_sources", {:force=>true}) -> 0.0135s -- create_table("custom_fields", {:force=>true}) -> 0.0123s -- create_table("custom_fields_projects", {:id=>false, :force=>true}) 途中省略 == 20160416072926 RemovePositionDefaults: migrating =========================== -- change_column("boards", :position, :integer, {:default=>nil}) -> 0.0095s -- change_column("custom_fields", :position, :integer, {:default=>nil}) -> 0.0133s -- change_column("enumerations", :position, :integer, {:default=>nil}) -> 0.0107s -- change_column("issue_statuses", :position, :integer, {:default=>nil}) -> 0.0082s -- change_column("roles", :position, :integer, {:default=>nil}) -> 0.0084s -- change_column("trackers", :position, :integer, {:default=>nil}) -> 0.0091s == 20160416072926 RemovePositionDefaults: migrated (0.0601s) ================== == 20160529063352 AddRolesSettings: migrating ================================= -- add_column(:roles, :settings, :text) -> 0.0430s == 20160529063352 AddRolesSettings: migrated (0.0432s) ========================
- 初期データ作成
(root)MacBook-Air-2:redmine foo$ RAILS_ENV=production bundle exec rake redmine:load_default_data Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja ==================================== Default configuration data loaded.
- WEBrickで起動
(root)MacBook-Air-2:redmine foo$ bundle exec rails server webrick -e production => Booting WEBrick => Rails 4.2.7.1 application starting in production on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2016-01-01 20:55:35] INFO WEBrick 1.3.1 [2016-01-01 20:55:35] INFO ruby 2.0.0 (2014-05-08) [universal.x86_64-darwin14] [2016-01-01 20:55:35] INFO WEBrick::HTTPServer#start: pid=44346 port=3000
- admin / admin でログインすると、パスワード変更を要求される。
- データベーステーブル一覧
mysql> show tables; +-------------------------------------+ | Tables_in_redmine | +-------------------------------------+ | attachments | | auth_sources | | boards | | changes | | changeset_parents | | changesets | | changesets_issues | | comments | | custom_field_enumerations | | custom_fields | | custom_fields_projects | | custom_fields_roles | | custom_fields_trackers | | custom_values | | documents | | email_addresses | | enabled_modules | | enumerations | | groups_users | | import_items | | imports | | issue_categories | | issue_relations | | issue_statuses | | issues | | journal_details | | journals | | member_roles | | members | | messages | | news | | open_id_authentication_associations | | open_id_authentication_nonces | | projects | | projects_trackers | | queries | | queries_roles | | repositories | | roles | | roles_managed_roles | | schema_migrations | | settings | | time_entries | | tokens | | trackers | | user_preferences | | users | | versions | | watchers | | wiki_content_versions | | wiki_contents | | wiki_pages | | wiki_redirects | | wikis | | workflows | +-------------------------------------+ 55 rows in set (0.00 sec) mysql>
- データの状況
mysql> select table_name, table_rows from information_schema.tables where table_schema = 'redmine' order by 2 desc; +-------------------------------------+------------+ | table_name | table_rows | +-------------------------------------+------------+ | schema_migrations | 268 | | workflows | 144 | | enumerations | 9 | | issue_statuses | 6 | | roles | 5 | | users | 4 | | trackers | 3 | | email_addresses | 1 | | tokens | 1 | | user_preferences | 1 | | custom_fields_trackers | 0 | | journals | 0 |
- ユーザデータ
mysql> select id, login, hashed_password, firstname, lastname, admin, status, last_login_on from users; +----+-------+------------------------------------------+-----------+------------------+-------+--------+---------------------+ | id | login | hashed_password | firstname | lastname | admin | status | last_login_on | +----+-------+------------------------------------------+-----------+------------------+-------+--------+---------------------+ | 1 | admin | a99fe2fb647cb2a5e059e095c93d2ccc0588f76d | Redmine | Admin | 1 | 1 | 2016-12-07 21:38:41 | | 2 | | | | Anonymous users | 0 | 1 | NULL | | 3 | | | | Non member users | 0 | 1 | NULL | | 4 | | | | Anonymous | 0 | 0 | NULL | +----+-------+------------------------------------------+-----------+------------------+-------+--------+---------------------+ 4 rows in set (0.00 sec)
- ロールのpermissionはtext属性になっている。
mysql> select permissions from roles where id = 3; | permissions - :add_project - :edit_project - :close_project - :select_project_modules - :manage_members - :manage_versions - :add_subprojects - :view_issues - :add_issues - :edit_issues - :copy_issues - :manage_issue_relations - :manage_subtasks - :set_issues_private - :set_own_issues_private - :add_issue_notes - :edit_issue_notes - :edit_own_issue_notes - :view_private_notes - :set_notes_private - :delete_issues - :manage_public_queries - :save_queries - :view_issue_watchers - :add_issue_watchers - :delete_issue_watchers - :import_issues - :manage_categories - :view_time_entries - :log_time - :edit_time_entries - :edit_own_time_entries - :manage_project_activities - :manage_news - :comment_news - :view_documents - :add_documents - :edit_documents - :delete_documents - :view_files - :manage_files - :view_wiki_pages - :view_wiki_edits - :export_wiki_pages - :edit_wiki_pages - :rename_wiki_pages - :delete_wiki_pages - :delete_wiki_pages_attachments - :protect_wiki_pages - :manage_wiki - :view_changesets - :browse_repository - :commit_access - :manage_related_issues - :manage_repository - :add_messages - :edit_messages - :edit_own_messages - :delete_messages - :delete_own_messages - :manage_boards - :view_calendar - :view_gantt | 1 row in set (0.00 sec) mysql>
Elastic Stackメモ
- Elastic Stack
- 総称した製品
- Elastc Cloud もある
- Logstash —> Elasticsearch -> Kibana
- x-pack
- 商用の拡張プラグイン
- x-packいろいろ入れると初回起動は遅くなる。
- Logstash ログ収集、加工、転送
- 設定ファイル input / filter / output
- プラグイン多数
- Kibana
- UI
- logstach と elastic search
- ロールは2種類ある
- クラスタに対する設定
- インデックスに対する設定
Logstash | elastic search | kibana | |
---|---|---|---|
実装 | ruby | Java | JavaScript |
起動 | logstash-5.0.0/bin/logstash -f complete.conf | elasticsearch-5.0.0/bin/elasticsearch | kibana-5.0.0-darwin-x86_64/bin/kibana |
Github | github.com | github.com | github.com |
ドキュメント | github.com | github.com | |
ベース技術 | Lucene | Node.js | |
Elasticスタックではじめるログ解析入門 #osc16ep // Speaker Deck
- data/node ディレクトリにデータとインデックスが格納されている。
- バケットという概念
Data types à la carte の写経
直和型を構成するところがわからなかったので写経してみました。
論文のコードと異なるところは
- Functorはderivingした
- 適宜showを実装した
- Exprにデストラクタoutを追加
- Free Monadの構成のところで、Applicativeを追加した(ただし、Applicativeの実装はわからなかったので適当につくった)。
型だけでReaderモナドを理解しようと試みる
Reader Monad は 昔 Environment Monad と呼ばれていたそうです。
ということで(!?)、設定ファイルを使う体で例を作ってみました。
設定ファイルを使わないと、
doJob123' = \x -> doJob3' x $ doJob2' x $ doJob1' x ()
となります。ここでいうx
が設定情報に相当する部分なのですが、コード上ずっと持ち回る必要があり、コードが読みにくくなります。
Readerモナドをつかうと、
doJobR123 = doJobR1 () >>= doJobR2 >>= doJobR3
となり、設定情報の持ち回りコードが隠蔽化されます。
JavaでReaderモナドを理解してみる
Readerモナドはdependency Injectionとして理解してみると良いかもしれません。
Java開発で言えば、Web開発でよくDependency Injectionがでてきます。例えば、フレームワークにSpringをつかうと、こんな感じでしょうか。
package hello; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class GreetingController { @RequestMapping("/greeting") public String greeting(Model model) { ... modelをつかってなにかする return "greeting"; } }
これをhaskellっぽく描くとこんな感じになるのではないでしょうか?
greeting :: Reader Model String greeting = do model <- ask ... modelをつかってなにかする return "greeting" runReader greeting model
正確さは欠けると思いますが、、。
brewでpostgresqlの起動停止
起動
(root)MacBook-Air-2:test$ brew services start postgresql ==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
停止
(root)MacBook-Air-2:test$ brew services stop postgresql Stopping `postgresql`... (might take a while) ==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql) (root)MacBook-Air-2:eccube ogawanaoto$
MacでのF#の環境設定
- Monoのインストール
- 指示に従ってインストールする
- インストールされる中身
This README is for Mono.framework 4.6.2_7. This is the Mono Runtime and Development Platform (http://www.mono-project.com/). This package installs Mono and all of its dependencies inside of /Library/Frameworks/Mono.framework. This behavior is likely to change with a future release so that dependancies will get their own frameworks. The following components are included inside Mono.framework: autoconf v. 2.69 automake v. 1.13 gettext v. 0.18.2 pkg-config v. 0.27 libpng v. 1.4.12 libjpeg v. 8 tiff v. 4.0.3 giflib v. 4.1.6 libxml2 v. 2.9.1 freetype v. 2.5.0.1 fontconfig v. 2.10.2 pixman v. 0.30.0 cairo v. 1.12.14 libffi v. 3.0.13 glib v. 2.36.4 pango v. 1.35.0 atk v. 2.8.0 intltool v. 0.50.2 gdk-pixbuf v. 2.28.2 gtk+ v.2.24 (master-2.24.22-3-g280fc40) libglade v. 2.6.4 sqlite-autoconf v. 3090200 expat v. 2.0.1 ige-mac-integration v. 0.9.4 libcroco v. 0.6.8 librsvg v. 2.37.0 hicolor-icon-theme v. 0.12 gtk-engines v. 2.20.2 murrine v. 0.98.2 xamarin-gtk-theme v.0.98.2 (master-cc3fb66) gtk-quartz-engine v.0.1 (master-v0.1-29-g9555a08) llvm v.3.0 (master-8b1520c) mono v.4.6.2 (mono-4.6.0-branch-mono-4.6.2.6-1-g08fd525) msbuild v.14.1 (xplat-p1-dcc94a7) PortableReferenceAssemblies v. 2014-04-14 libgdiplus v. 2.11 xsp v. 4.4 gtk-sharp v. 2.12.21 iron-languages v. 2.11 fsharp v. 4.0.1.9 mono-basic v. 4.6 nuget v.2.12.0 (master-2.7.1-605-g9e2d2c1) mono-extensions (mono-4.6.0-branch-4f354fd) ms-test-suite v.0.1 (master-eb7cd70) Other packages used to build Mono.framework: bockbuild (rev. d9a428be30fff40c638e99ee7751588565eb98c5) autoconf v. 2.69 automake v. 1.13 ccache v.3.1.9 (master-v3.1.9-321-g55f1fc6) libtool v. 2.4.2 xz v. 5.0.4 tar v. 1.26 gtk-osx-docbook v. 1.0 gtk-doc v. 1.18 If you want to build native Mac applications with Mono, you can use the MonoMac bindings, an add-on to this product available from http://www.mono-project.com/MonoMac A simple uninstallMono.sh script is included in the disk image. This is shell script that must be run as root, and it will remove the Mono.framework and the links in /usr/bin. This package was created by the Mono team. Major contributors to this team include (in alphabetical order): Wade Berrier Adhamh Findlay Miguel de Icaza Urs Muff Geoff Norton Andy Satori Questions or problems related directly to the Mono.framework should be addressed to mono-osx@lists.xamarin.com. Questions about Mono should be directed to an appropriate resource that can be found on http://www.mono-project.com/about.
export PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/Current/bin
- Monoインストールの確認
$ mcs -help Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc mcs [options] source-files --about About the Mono C# compiler -addmodule:M1[,Mn] Adds the module to the generated assembly -checked[+|-] Sets default aritmetic overflow context -clscheck[+|-] Disables CLS Compliance verifications -codepage:ID Sets code page to the one in ID (number, utf8, reset) -define:S1[;S2] Defines one or more conditional symbols (short: -d) -debug[+|-], -g Generate debugging information -delaysign[+|-] Only insert the public key into the assembly (no signing) -doc:FILE Process documentation comments to XML file -fullpaths Any issued error or warning uses absolute file path -help Lists all compiler options (short: -?) -keycontainer:NAME The key pair container used to sign the output assembly -keyfile:FILE The key file used to strongname the ouput assembly -langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, 4, 5, Default or Experimental -lib:PATH1[,PATHn] Specifies the location of referenced assemblies -main:CLASS Specifies the class with the Main method (short: -m) -noconfig Disables implicitly referenced assemblies -nostdlib[+|-] Does not reference mscorlib.dll library -nowarn:W1[,Wn] Suppress one or more compiler warnings -optimize[+|-] Enables advanced compiler optimizations (short: -o) -out:FILE Specifies output assembly name -pkg:P1[,Pn] References packages P1..Pn -platform:ARCH Specifies the target platform of the output assembly ARCH can be one of: anycpu, anycpu32bitpreferred, arm, x86, x64 or itanium. The default is anycpu. -recurse:SPEC Recursively compiles files according to SPEC pattern -reference:A1[,An] Imports metadata from the specified assembly (short: -r) -reference:ALIAS=A Imports metadata using specified extern alias (short: -r) -sdk:VERSION Specifies SDK version of referenced assemblies VERSION can be one of: 2, 4, 4.5 (default) or a custom value -target:KIND Specifies the format of the output assembly (short: -t) KIND can be one of: exe, winexe, library, module -unsafe[+|-] Allows to compile code which uses unsafe keyword -warnaserror[+|-] Treats all warnings as errors -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors -warn:0-4 Sets warning level, the default is 4 (short -w:) -helpinternal Shows internal and advanced compiler options Resources: -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres) -resource:FILE[,ID] Embed FILE as a resource (short: -res) -win32res:FILE Specifies Win32 resource file (.res) -win32icon:FILE Use this icon for the output @file Read response file for more options Options can be of the form -option or /option
- Visual Studio Code に拡張機能をインストールする。
- Code Runner
- Ionide-fsharp fsharpのintellsence
- Ionide-FAKE fsharpのmake機能
- Ionide-Paket パッケージ管理?
- Mono Debug デバック環境
- 規定の設定に
Run Code configuration
のcode-runner.executorMap
のfsharp
の項目にfsi
が指定されている。別ファイルのsetting.json
にfsharpi
を記述して、規定の設定を上書きする。
{ "code-runner.executorMap": { "fsharp": "fsharpi" } }
- 拡張子
fsx
のファイルを作成し、コードを書く。
let helloWorld = "Hello world from fsharpi" printfn "%s" helloWorld
- コンテキストメニューよりRun Codeする。