Skip to content

Commit

Permalink
Merge pull request #79 from sebalix/fix/init_logfile
Browse files Browse the repository at this point in the history
[FIX] Let systemd/journalctl handles the logs by default + new variable 'odoo_logfile'...
  • Loading branch information
JordiBForgeFlow authored Mar 19, 2018
2 parents 65ee869 + 3f53ad9 commit e434f07
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ odoo_init_env: {}
#VAR1: value1
#VAR2: value2
odoo_logdir: "/var/log/{{ odoo_user }}"
odoo_logfile: "{{ ansible_service_mgr != 'systemd' and ('/'.join([odoo_logdir, odoo_service]) + '.log') or ''}}"
odoo_workdir: "/home/{{ odoo_user }}/odoo"
odoo_rootdir: "{{ odoo_install_type == 'buildout' and '/home/'+odoo_user+'/odoo/parts/odoo' or '/home/'+odoo_user+'/odoo/server' }}"

Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-10.0.init
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DAEMON={{ odoo_rootdir }}/odoo-bin
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
LOGFILE={{ odoo_logdir }}/{{ odoo_service }}.log
LOGFILE={{ odoo_logfile }}
PIDFILE=/var/run/${NAME}.pid
USER={{ odoo_user }}
export LOGNAME=$USER
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-8.0.init
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DAEMON={{ odoo_rootdir }}/odoo.py
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
LOGFILE={{ odoo_logdir }}/{{ odoo_service }}.log
LOGFILE={{ odoo_logfile }}
PIDFILE=/var/run/${NAME}.pid
USER={{ odoo_user }}
export LOGNAME=$USER
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-9.0.init
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DAEMON={{ odoo_rootdir }}/odoo.py
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
LOGFILE={{ odoo_logdir }}/{{ odoo_service }}.log
LOGFILE={{ odoo_logfile }}
PIDFILE=/var/run/${NAME}.pid
USER={{ odoo_user }}
export LOGNAME=$USER
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-buildout.init
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WORKDIR={{ odoo_workdir }}
DAEMON={{ odoo_buildout_odoo_bin_path }}
NAME={{ odoo_service }}
DESC={{ odoo_service }}
LOGFILE={{ odoo_logdir }}/{{ odoo_service }}.log
LOGFILE={{ odoo_logfile }}
PIDFILE=/var/run/${NAME}.pid
USER={{ odoo_user }}
export LOGNAME=$USER
Expand Down
3 changes: 2 additions & 1 deletion templates/odoo-buildout.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ After=network.target
Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
ExecStart={{ odoo_buildout_odoo_bin_path }}
ExecStart={{ odoo_buildout_odoo_bin_path }}{{ odoo_logfile and ' --logfile %s' % odoo_logfile }}
KillMode=mixed
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-pip.init
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DAEMON={{ odoo_pip_odoo_bin_path }}
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
LOGFILE={{ odoo_logdir }}/{{ odoo_service }}.log
LOGFILE={{ odoo_logfile }}
PIDFILE=/var/run/${NAME}.pid
USER={{ odoo_user }}
export LOGNAME=$USER
Expand Down
3 changes: 2 additions & 1 deletion templates/odoo-pip.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ After=network.target
Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
ExecStart={{ odoo_pip_odoo_bin_path }} --logfile {{ odoo_logdir }}/{{ odoo_service}}.log --config {{ odoo_config_file }}
ExecStart={{ odoo_pip_odoo_bin_path }}{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
KillMode=mixed
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
{% endfor %}
Expand Down
5 changes: 3 additions & 2 deletions templates/odoo-standard.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
{% if odoo_version | version_compare('10.0', '>=') %}
ExecStart={{ odoo_rootdir }}/odoo-bin --logfile {{ odoo_logdir }}/{{ odoo_service }}.log --config {{ odoo_config_file }}
ExecStart={{ odoo_rootdir }}/odoo-bin{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
KillMode=mixed
{% else %}
ExecStart={{ odoo_rootdir }}/odoo.py --logfile {{ odoo_logdir }}/{{ odoo_service}}.log --config {{ odoo_config_file }}
ExecStart={{ odoo_rootdir }}/odoo.py{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
{% endif %}
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
Expand Down

0 comments on commit e434f07

Please sign in to comment.