|
40 | 40 |
|
41 | 41 | default_conf_dir = platform_family?('rhel', 'amazon') ? '/etc/sysconfig' : '/etc/default' |
42 | 42 |
|
| 43 | + service_config = { |
| 44 | + Type: 'notify', |
| 45 | + RuntimeDirectory: 'elasticsearch', |
| 46 | + PrivateTmp: 'true', |
| 47 | + Environment: [ |
| 48 | + "ES_HOME=#{es_conf.path_home}", |
| 49 | + 'ES_PATH_CONF=/etc/elasticsearch', |
| 50 | + "PID_DIR=#{es_conf.path_pid}", |
| 51 | + 'ES_SD_NOTIFY=true', |
| 52 | + ], |
| 53 | + EnvironmentFile: "-#{default_conf_dir}/#{new_resource.service_name}", |
| 54 | + WorkingDirectory: es_conf.path_home.to_s, |
| 55 | + User: es_user.username, |
| 56 | + Group: es_user.groupname, |
| 57 | + ExecStart: "#{es_conf.path_home}/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet", |
| 58 | + StandardOutput: 'journal', |
| 59 | + StandardError: 'inherit', |
| 60 | + LimitNOFILE: '65535', |
| 61 | + LimitNPROC: '4096', |
| 62 | + LimitAS: 'infinity', |
| 63 | + LimitFSIZE: 'infinity', |
| 64 | + TimeoutStopSec: '0', |
| 65 | + KillSignal: 'SIGTERM', |
| 66 | + KillMode: 'process', |
| 67 | + SendSIGKILL: 'no', |
| 68 | + SuccessExitStatus: '143', |
| 69 | + TimeoutStartSec: '900', |
| 70 | + } |
| 71 | + |
| 72 | + service_config[:Restart] = new_resource.restart_policy if new_resource.restart_policy && !new_resource.restart_policy.empty? |
| 73 | + service_config[:RestartSec] = new_resource.restart_sec if new_resource.restart_sec |
| 74 | + |
43 | 75 | systemd_unit new_resource.service_name do |
44 | 76 | content( |
45 | 77 | Unit: { |
|
48 | 80 | Wants: 'network-online.target', |
49 | 81 | After: 'network-online.target', |
50 | 82 | }, |
51 | | - Service: { |
52 | | - Type: 'notify', |
53 | | - RuntimeDirectory: 'elasticsearch', |
54 | | - PrivateTmp: 'true', |
55 | | - Environment: [ |
56 | | - "ES_HOME=#{es_conf.path_home}", |
57 | | - 'ES_PATH_CONF=/etc/elasticsearch', |
58 | | - "PID_DIR=#{es_conf.path_pid}", |
59 | | - 'ES_SD_NOTIFY=true', |
60 | | - ], |
61 | | - EnvironmentFile: "-#{default_conf_dir}/#{new_resource.service_name}", |
62 | | - WorkingDirectory: "#{es_conf.path_home}", |
63 | | - User: es_user.username, |
64 | | - Group: es_user.groupname, |
65 | | - ExecStart: "#{es_conf.path_home}/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet", |
66 | | - StandardOutput: 'journal', |
67 | | - StandardError: 'inherit', |
68 | | - LimitNOFILE: '65535', |
69 | | - LimitNPROC: '4096', |
70 | | - LimitAS: 'infinity', |
71 | | - LimitFSIZE: 'infinity', |
72 | | - TimeoutStopSec: '0', |
73 | | - KillSignal: 'SIGTERM', |
74 | | - KillMode: 'process', |
75 | | - SendSIGKILL: 'no', |
76 | | - SuccessExitStatus: '143', |
77 | | - TimeoutStartSec: '900', |
78 | | - Restart: new_resource.restart_policy if new_resource.restart_policy, |
79 | | - RestartSec: new_resource.restart_sec if new_resource.restart_sec |
80 | | - }, |
| 83 | + Service: service_config, |
81 | 84 | Install: { |
82 | 85 | WantedBy: 'multi-user.target', |
83 | 86 | } |
|
0 commit comments