質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Gunicorn

Gunicorn (Green Unicorn)は、Rubyのunicornをベースに開発されたUNIX向けのPython製HTTPサーバです。他のライブラリとの依存関係がないため、容易にインストールして使用できます。

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Q&A

解決済

2回答

4233閲覧

[質問] systemd ExecStartPre=source file でエラーになってしまう

roswell

総合スコア17

Gunicorn

Gunicorn (Green Unicorn)は、Rubyのunicornをベースに開発されたUNIX向けのPython製HTTPサーバです。他のライブラリとの依存関係がないため、容易にインストールして使用できます。

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

0グッド

0クリップ

投稿2018/12/24 09:05

yama@jpx20120007:~$ lsb_release -a No LSB modules are available. Distributor ID: LinuxMint Description: LMDE 3 Cindy Release: 3 Codename: cindy

の環境の systemdで、virtualenv の activate

ExecStartPre=source /home/yama/reminiscense/venv/bin/activate

を実行すると、

[/etc/systemd/system/reminiscence.service:14] Executable path is not absolute, ignoring: source /home/yama/reminiscense/venv/bin/activate

となってしまいます。
対処方法をご教示頂けますでしょうか?
ちなみに、systemd ではなく、コマンドラインより、
WorkingDirectoryにて、ExecStartPre及び、ExecStart を手動実行すると、
動作します。

下記が、systemdでの実行結果の詳細になります。

yama@jpx20120007:~$ cat /etc/systemd/system/reminiscence.service [Unit] Description="reminiscence systemctl setting file' # for gunicorn [Service] User=yama WorkingDirectory=/home/yama/reminiscence/venv/reminiscence ExecStartPre=source /home/yama/reminiscense/venv/bin/activate ExecStart=/home/yama/reminiscence/venv/bin/gunicorn --daemon --max-requests 100 --worker-class gthread --workers 2 --thread 5 --timeout 300 --bind 0.0.0.0:8000 reminiscence.wsgi [Install] WantedBy=multi-user.target yama@jpx20120007:~$ sudo systemctl stop reminiscence Warning: reminiscence.service changed on disk. Run 'systemctl daemon-reload' to reload units. yama@jpx20120007:~$ sudo systemctl daemon-reload yama@jpx20120007:~$ sudo systemctl stop reminiscence yama@jpx20120007:~$ sudo systemctl start reminiscence yama@jpx20120007:~$ sudo systemctl status reminiscence ● reminiscence.service - "reminiscence systemctl setting file' Loaded: loaded (/etc/systemd/system/reminiscence.service; disabled; vendor preset: enabled) Active: inactive (dead) ... 12月 24 17:56:48 jpx20120007.ifs.sony.co.jp systemd[1]: Started "reminiscence systemctl setting file'. 12月 24 17:56:52 jpx20120007.ifs.sony.co.jp systemd[1]: [/etc/systemd/system/reminiscence.service:14] Executable path is not absolute, ignoring: source /home/yama/reminiscense/venv/bin/activate yama@jpx20120007:~$ cat /home/yama/reminiscence/venv/bin/activate # This file must be used with "source bin/activate" *from bash* # you cannot run it directly deactivate () { unset -f pydoc >/dev/null 2>&1 # reset old environment variables # ! [ -z ${VAR+_} ] returns true if VAR is declared at all if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then PATH="$_OLD_VIRTUAL_PATH" export PATH unset _OLD_VIRTUAL_PATH fi if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" export PYTHONHOME unset _OLD_VIRTUAL_PYTHONHOME fi # This should detect bash and zsh, which have a hash command that must # be called to get it to forget past commands. Without forgetting # past commands the $PATH changes we made may not be respected if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then hash -r 2>/dev/null fi if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then PS1="$_OLD_VIRTUAL_PS1" export PS1 unset _OLD_VIRTUAL_PS1 fi unset VIRTUAL_ENV if [ ! "${1-}" = "nondestructive" ] ; then # Self destruct! unset -f deactivate fi } # unset irrelevant variables deactivate nondestructive VIRTUAL_ENV="/home/yama/reminiscence/venv" export VIRTUAL_ENV _OLD_VIRTUAL_PATH="$PATH" PATH="$VIRTUAL_ENV/bin:$PATH" export PATH # unset PYTHONHOME if set if ! [ -z "${PYTHONHOME+_}" ] ; then _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" unset PYTHONHOME fi if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then _OLD_VIRTUAL_PS1="$PS1" if [ "x" != x ] ; then PS1="$PS1" else PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1" fi export PS1 fi # Make sure to unalias pydoc if it's already there alias pydoc 2>/dev/null >/dev/null && unalias pydoc pydoc () { python -m pydoc "$@" } # This should detect bash and zsh, which have a hash command that must # be called to get it to forget past commands. Without forgetting # past commands the $PATH changes we made may not be respected if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then hash -r 2>/dev/null fi

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

/etc/systemd/system/reminiscence.serviceをルート(/)からの完全なパス(絶対パス)に書き換えると解決するのではないでしょうか。

は、/ から始まっているので、絶対パスで、

問題は

'''
12月 24 17:56:52 jpx20120007.ifs.sony.co.jp systemd[1]: [/etc/systemd/system/reminiscence.service:14] Executable path is not absolute, ignoring: source /home/yama/reminiscense/venv/bin/activate
'''

の ignoring: 部分
source /home/yama/reminiscense/venv/bin/activate
なのです。

その後、検索して
(https://unix.stackexchange.com/questions/274861/systemd-bash-builtins/274869#274869)
っぽいかなと思い、真似て、

'''
ExecStart=/bin/bash -c 'source /home/yama/reminiscence/venv/bin/activate;/home/yama/reminiscence/venv/bin/gunicorn --daemon --max-requests 100 --worker-class gthread --workers 2 --thread 5 --timeout 300 --bind 0.0.0.0:8000 reminiscence.wsgi'
'''
で、動作するようになりました。

投稿2018/12/25 04:35

roswell

総合スコア17

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

エラーメッセージは、[/etc/systemd/system/reminiscence.service:14] Executable path is not absolute (実行パスが絶対パスになっていない(相対パスではダメ!)という内容なので、
/etc/systemd/system/reminiscence.serviceをルート(/)からの完全なパス(絶対パス)に書き換えると解決するのではないでしょうか。

投稿2018/12/24 09:41

coco_bauer

総合スコア6915

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問