LoginSignup
1
2

【Redmine】Work Timeプラグインのインストール手順

Last updated at Posted at 2024-02-02

ふとWork Timeプラグインの導入を思い立ち、以下のプラグインの公式ページに記載の方法でインストールを試みたのですが、うまくいかない点があったので備忘録として残します。

なお,使用するコマンドの解説は行なっておりません.予めご了承ください...

環境

  • Redmineサーバマシン:Raspberry Pi 4 Model B

インストール手順

1. ZIPファイルのダウンロード

プラグインのソースをダウンロードします(ダウンロード先はどこでもOK)。2024/2/2時点の最新版は 0.4.1 でした。

bash
$ wget https://github.com/tkusukawa/redmine_work_time/archive/refs/tags/0.4.1.zip

2. pluginsディレクトリ直下に中身を解凍

ダウンロードしたZIPファイルの中身を<Redmineのインストールディレクトリ>/pluginsに格納します。私の場合は/var/lib/redmine/pluginsに格納しました。

Redmineのインストールディレクトリの調べ方

bash
$ unzip 0.4.1.zip -d <Redmineのインストールディレクトリ>/plugins

上記コマンド実行後、<Redmineのインストールディレクトリ>/pluginsディレクトリ直下にredmine_work_time-0.4.1というディレクトリが格納されます。

プラグインの公式ページには記載がありませんでしたが、redmine_work_time-0.4.1という名前では次に紹介するマイグレーション時にエラーが発生してしまいます。そのため、名前をredmine_work_time-0.4.1からredmine_work_timeに変更します(と同時に、pluginsディレクトリへの移動も行っています)。

bash
$ cd <Redmineのインストールディレクトリ>/plugins && mv redmine_work_time-0.4.1 redmine_work_time

3. プラグインのマイグレーション

Work Timeプラグインを導入するための、データベースのマイグレーションを実行します。pluginsディレクトリにいる状態で以下のマイグレーションコマンドを実行します。

bash
$ RAILS_ENV=production bundle exec rake redmine:plugins:migrate

エラー発生時の対策

マイグレーションコマンド実行時に、

Rails Error: Unable to access log file. 
Please ensure that /var/lib/redmine/log/production.log exists and 
is writable (ie, make it writable for user and group: 
chmod 0664 /var/lib/redmine/log/production.log). 
The log level has been raised to WARN and the output directed to 
STDERR until the problem is fixed.

といったエラーが発生した場合は以下のコマンドを実行して、再度上記マイグレーションコマンドを実行してみてください。

bash
$ sudo chmod 666 <Redmineのインストールディレクトリ>/log/production.log

そのほか、

Could not create directory 
/var/lib/redmine/public/plugin_assets/redmine_work_time/javascripts: 
Permission denied @ dir_s_mkdir - 
/var/lib/redmine/public/plugin_assets/redmine_work_time

というエラーが発生した場合はsudoをつけてマイグレーションコマンドを実行してみてください。

bash
$ sudo RAILS_ENV=production bundle exec rake redmine:plugins:migrate

マイグレーション完了時の表示

== 1 CreateUserIssueMonths: migrating =========================================
-- create_table(:user_issue_months, {:id=>:integer})
   -> 0.0780s
== 1 CreateUserIssueMonths: migrated (0.0783s) ================================

== 2 CreateWtMemberOrders: migrating ==========================================
-- create_table(:wt_member_orders, {:id=>:integer})
   -> 0.0144s
== 2 CreateWtMemberOrders: migrated (0.0147s) =================================

== 3 CreateWtTicketRelays: migrating ==========================================
-- create_table(:wt_ticket_relays, {:id=>:integer})
   -> 0.0139s
== 3 CreateWtTicketRelays: migrated (0.0142s) =================================

== 4 AddPrjToMemOdr: migrating ================================================
-- add_column(:wt_member_orders, :prj_id, :integer, {:default=>nil})
   -> 0.0035s
== 4 AddPrjToMemOdr: migrated (0.0038s) =======================================

== 5 CreateWtDailyMemos: migrating ============================================
-- create_table(:wt_daily_memos, {:id=>:integer})
   -> 0.0193s
== 5 CreateWtDailyMemos: migrated (0.0196s) ===================================

== 6 CreateWtProjectOrders: migrating =========================================
-- create_table(:wt_project_orders, {:id=>:integer})
   -> 0.0122s
== 6 CreateWtProjectOrders: migrated (0.0125s) ================================

== 7 CreateWtHolidays: migrating ==============================================
-- create_table(:wt_holidays, {:id=>:integer})
   -> 0.0669s
== 7 CreateWtHolidays: migrated (0.0672s) =====================================

== 8 RemoveMonthFromUserIssueMonth: migrating =================================
-- remove_column(:user_issue_months, :month)
   -> 0.0049s
== 8 RemoveMonthFromUserIssueMonth: migrated (0.0052s) ========================

== 9 RemovePrjFromWtProjectOrders: migrating ==================================
-- remove_column(:wt_project_orders, :prj)
   -> 0.0020s
== 9 RemovePrjFromWtProjectOrders: migrated (0.0023s) =========================

マイグレーションコマンド実行時に上記の内容が出力されればマイグレーション完了となります。

4. Redmineの再起動

あとはRedmineを再起動するだけです。再起動の方法はいくつかあるようですが、今回は空のファイルrestart.txt<Redmineのインストールディレクトリ>/tmpディレクトリに格納する方法で行いました。

bash
$ touch <Redmineのインストールディレクトリ>/tmp/restart.txt

上記コマンドを実行後、ブラウザ上でリロードすると再起動が行われます。
以上でインストール完了となります。

インストール完了後は...

以下の記事の [Work Timeプラグインの有効化・設定] が参考になりました。

追記: Redmineのインストールディレクトリの調べ方

Redmineのインストールディレクトリを忘れてしまった場合のため,しばらくその調べ方を探していました.以下の公式ページを発見したのですが,私の環境ではうまく調べることができませんでした.

そこで,私なりに考えた調べ方を提案します.

Redmineで使用しているWebサーバとアプリケーションサーバが1つのマシンに同居していることを前提とします.

まず,Redmineで使用しているWebサーバを調べます.Redmineで使用しているポート番号を使用します.

RedmineのURLhttp[s]:/hogehoge:foo/redmineのうち,fooの値がポート番号です(URLがhttp[s]:/hogehoge/redmineの場合,一般的には 80 番です).

このポート番号を使用して以下のlsofコマンドを実行します.

bash
$ sudo lsof -i:<ポート番号>

ここで表示されたCOMMANDの名称が,稼働しているRedmineのWebサーバの名称となります.

以下は私の環境での実行結果ですが,Webサーバはapache2を使用しているようです.

COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
apache2  954     root    3u  IPv4   3894      0t0  TCP *:http (LISTEN)
apache2 2345 www-data    3u  IPv4   3894      0t0  TCP *:http (LISTEN)
apache2 2346 www-data    3u  IPv4   3894      0t0  TCP *:http (LISTEN)

この名称を使用して以下のsystemctlコマンドを実行します.

bash
$ sudo systemctl status <COMMANDの名称>

すると,使用しているWebサーバに関するステータスがずらっと表示されるかと思います.

ここでCGroupという項目に注目します.この項目のうち,[使用しているアプリケーションサーバ名] RubyApp:という箇所の値がRedmineのインストールディレクトリとなります.

以下は私の環境での実行結果ですが,インストールディレクトリは/var/lib/redmineであることがわかりました.

CGroup: /system.slice/apache2.service
             ├─ 954 /usr/sbin/apache2 -k start
             ├─2327 Passenger watchdog
             ├─2332 Passenger core
             ├─2345 /usr/sbin/apache2 -k start
             ├─2346 /usr/sbin/apache2 -k start
             └─2962 Passenger RubyApp: /var/lib/redmine (production)
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2