Xenial: add a service file

Add a service file for later Ubuntu versions.  Centralise the logging
into init.pp as it's not as easy to get logs to file from stdout/err
via systemd.  Fix up the logrotation while we're there

Change-Id: I43ea764d070fb44502bda0c845485769dace6ff3
This commit is contained in:
Ian Wienand 2017-12-18 15:02:26 +11:00
parent ad5cc1f357
commit 7cf08e1e39
3 changed files with 85 additions and 36 deletions

View File

@ -106,46 +106,77 @@ class etherpad_lite (
creates => "${base_install_dir}/etherpad-lite/node_modules",
}
file { '/etc/init/etherpad-lite.conf':
ensure => present,
content => template('etherpad_lite/upstart.erb'),
replace => true,
owner => 'root',
}
case $::operatingsystem {
'Ubuntu': {
if $::operatingsystemrelease <= '14.04' {
file { '/etc/init.d/etherpad-lite':
ensure => link,
target => '/lib/init/upstart-job',
}
file { '/etc/init/etherpad-lite.conf':
ensure => present,
content => template('etherpad_lite/upstart.erb'),
replace => true,
owner => 'root',
}
file { "${base_log_dir}/${ep_user}":
ensure => directory,
owner => $ep_user,
}
file { '/etc/init.d/etherpad-lite':
ensure => link,
target => '/lib/init/upstart-job',
}
include ::logrotate
logrotate::file { 'epliteerror':
log => "${base_log_dir}/${ep_user}/error.log",
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
}
file { "${base_log_dir}/${ep_user}":
ensure => directory,
owner => $ep_user,
}
logrotate::file { 'epliteaccess':
log => "${base_log_dir}/${ep_user}/access.log",
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
include ::logrotate
logrotate::file { 'epliteerror':
log => "${base_log_dir}/${ep_user}/error.log",
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
}
logrotate::file { 'epliteaccess':
log => "${base_log_dir}/${ep_user}/access.log",
options => [
'compress',
'copytruncate',
'missingok',
'rotate 7',
'daily',
'notifempty',
],
}
} else {
# Note logs go to syslog, can maybe change when
# https://github.com/systemd/systemd/pull/7198 is available
file { '/etc/systemd/system/etherpad-lite.service':
ensure => present,
content => template('etherpad_lite/etherpad-lite.service.erb'),
replace => true,
owner => 'root',
require => Exec['install_etherpad_dependencies'],
}
# This is a hack to make sure that systemd is aware of the new service
# before we attempt to start it.
exec { 'etherpad-lite-systemd-daemon-reload':
command => '/bin/systemctl daemon-reload',
refreshonly => true,
require => File['/etc/systemd/system/etherpad-lite.service'],
}
}
}
default: {
fail('This operating system not supported')
}
}
# end package management ugliness

View File

@ -28,6 +28,7 @@ class etherpad_lite::site (
group => $etherpad_lite::ep_user,
mode => '0600',
require => Class['etherpad_lite'],
before => Service['etherpad-lite'],
}
file { "${base}/etherpad-lite/src/static/custom/pad.js":
@ -37,6 +38,7 @@ class etherpad_lite::site (
group => $etherpad_lite::ep_user,
mode => '0644',
require => Class['etherpad_lite'],
before => Service['etherpad-lite'],
}
}

View File

@ -0,0 +1,16 @@
[Unit]
Description=Etherpad-lite, the collaborative editor.
After=syslog.target network.target
[Service]
Type=simple
User=<%= @ep_user %>
Group=<%= @ep_user %>
WorkingDirectory=<%= @base_install_dir %>/etherpad-lite
ExecStart=/usr/bin/nodejs node_modules/ep_etherpad-lite/node/server.js
Restart=always
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target