###実現したいこと
Lodgeで使用するSolr(sunspot)を、CentOS7起動時に自動的に起動したい。
[Lodge]
https://github.com/lodge/lodge
###Lodgeで使用する機能
- Solr(Sunspot)
- Unicorn
[手動起動時のコマンド]
0. cd /root/lodge 1. bin/rake sunspot:solr:start RAILS_ENV=production 2. bundle exec unicorn -c config/unicorn.rb -E production
手動であれば、上記コマンドを打てばLodgeが使える環境になっています。
###発生している問題
systemdで自動的に起動させると、Solr(sunspot)の起動で
「~ /usr/bin/env: ruby: そのようなファイルやディレクトリはありません」
というエラーが発生します。
[root@localhost ~]# systemctl status sunspot-startup.service -l ● sunspot-startup.service - sunspot starter Loaded: loaded (/etc/systemd/system/sunspot-startup.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since 木 2017-06-15 09:34:17 JST; 1min 32s ago Process: 577 ExecStart=/root/lodge/bin/rake sunspot:solr:start RAILS_ENV=production (code=exited, status=127) Main PID: 577 (code=exited, status=127) 6月 15 09:34:17 localhost.localdomain systemd[1]: Started sunspot starter. 6月 15 09:34:17 localhost.localdomain systemd[1]: Starting sunspot starter... 6月 15 09:34:17 localhost.localdomain rake[577]: /usr/bin/env: ruby: そのようなファイルやディレクトリはありません 6月 15 09:34:17 localhost.localdomain systemd[1]: sunspot-startup.service: main process exited, code=exited, status=127/n/a 6月 15 09:34:17 localhost.localdomain systemd[1]: Unit sunspot-startup.service entered failed state. 6月 15 09:34:17 localhost.localdomain systemd[1]: sunspot-startup.service failed.
###systemdの設定値
sunspot-startup.serviceの設定は、以下のようにしています。
[Unit] Type=simple Description=sunspot starter [Service] WorkingDirectory=/root/lodge ExecStart=/root/lodge/bin/rake sunspot:solr:start RAILS_ENV=production [Install] WantedBy=multi-user.target
###試したこと
.bashrcに対し、下記URLを参考に2行追加 → 効果なし
http://d.hatena.ne.jp/japanrock_pg/20090527/1243426081
[root@localhost ~]# more .bashrc # .bashrc ~略~ . /etc/bashrc fi # 追加部分 export PATH=/usr/local/bin:$PATH alias sudo="sudo env PATH=$PATH"
systemdで、Lodgeを起動するをシェル(下記)を呼ぶ → 効果なし(本件と同じエラーが発生)
#!/bin/sh script_dir="cd /root/lodge" sunspot="bin/rake sunspot:solr:start RAILS_ENV=production" lodge="bundle exec unicorn -c config/unicorn.rb -E production" eval $script_dir eval $sunspot eval $lodge
###補足情報(言語/FW/ツール等のバージョンなど)
OS: CentOS7 (VirtualBox 5.1.22)
Ruby: 2.2.7p470 (rbenv)
Gem: 2.4.5.2
Rails: 4.1.14
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。