Skip to content

Commit

Permalink
Install systemd script with deb and fix related issues
Browse files Browse the repository at this point in the history
Previously in the deb the init.d script was included, but not the
systemd script. FPM has an option for it, so this PR adds that option.
This results in the systemd script being installed when you install the
deb. That makes interfacing through puppet easier using Service.

This uncovered an issue with the previous systemd script where the log
file option wasn't taking effect because the "foreground" command
logged to stdout.

This PR also updates the systemd script to work around that issue.
  • Loading branch information
jason-o-matic committed May 17, 2017
1 parent 6583871 commit 74f3b77
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -41,7 +41,7 @@ SUPPORTED_DISTROS = {
]
}
EXTRA_ARGS = {
'deb' => '--deb-init debian/instrumentald --after-install debian/after-install.sh --before-remove debian/before-remove.sh --after-remove debian/after-remove.sh --deb-user nobody --deb-group nogroup',
'deb' => '--deb-init debian/instrumentald --deb-systemd systemd/instrumentald.service --after-install debian/after-install.sh --before-remove debian/before-remove.sh --after-remove debian/after-remove.sh --deb-user nobody --deb-group nogroup',
'rpm' => '--rpm-init rpm/instrumentald --after-install rpm/after-install.sh --before-remove rpm/before-remove.sh --after-remove rpm/after-remove.sh --rpm-user nobody --rpm-group nobody --rpm-os linux --rpm-attr "-,nobody,nobody:/opt/instrumentald/" --directories /opt/instrumentald/',
"osxpkg" => "--osxpkg-identifier-prefix com.instrumentalapp --name instrumentald --after-install osx/after-install.sh --osxpkg-dont-obsolete /etc/instrumentald.toml", # remove doesn't exist on osx
}
Expand Down
5 changes: 5 additions & 0 deletions puppet/.kitchen.yml
Expand Up @@ -23,6 +23,11 @@ platforms:
driver_config:
box: nocm_ubuntu-12.04
box_url: https://atlas.hashicorp.com/puppetlabs/boxes/ubuntu-12.04-64-nocm/versions/1.0.1/providers/virtualbox.box
- name: nocm_ubuntu-16.04
driver_plugin: vagrant
driver_config:
box: nocm_ubuntu-16.04
box_url: https://atlas.hashicorp.com/puppetlabs/boxes/ubuntu-16.04-64-nocm/versions/1.0.0/providers/virtualbox.box
- name: nocm_centos-6.6
driver_plugin: vagrant
driver_config:
Expand Down
14 changes: 7 additions & 7 deletions puppet/instrumentald/manifests/init.pp
Expand Up @@ -38,15 +38,15 @@
owner => "nobody",
mode => "0700",
before => Package["instrumentald"],
notify => Exec["instrumentald-restart"]
notify => Service['instrumentald']
}

file { "/tmp/instrumentald_scripts/test_script.bash":
owner => "nobody",
mode => "0700",
before => Package["instrumentald"],
content => template("instrumentald/test_script.bash.erb"),
notify => Exec["instrumentald-restart"]
notify => Service['instrumentald']
}

file { "instrumental-config":
Expand All @@ -55,12 +55,12 @@
mode => "0440",
require => Package["instrumentald"],
content => template("instrumentald/instrumentald.toml.erb"),
notify => Exec["instrumentald-restart"]
notify => Service['instrumentald']
}

exec { "instrumentald-restart" :
refreshonly => true,
command => "/etc/init.d/instrumentald restart",
user => "root"
service { 'instrumentald':
ensure => 'running',
enable => true,
require => File['instrumental-config'],
}
}
8 changes: 5 additions & 3 deletions systemd/instrumentald.service
Expand Up @@ -4,9 +4,11 @@ After=syslog.target
After=network.target

[Service]
Type=simple
ExecStart=/opt/instrumentald/instrumentald -c /etc/instrumentald.toml -p /opt/instrumentald/instrumentald.pid -l /opt/instrumentald/instrumentald.log -s /opt/instrumentald/.instrumental_scripts -t /opt/instrumentald/ foreground

Type=forking
PIDFile=/opt/instrumentald/instrumentald.pid
ExecStart=/opt/instrumentald/instrumentald -c /etc/instrumentald.toml -p /opt/instrumentald/instrumentald.pid -l /opt/instrumentald/instrumentald.log -s /opt/instrumentald/.instrumental_scripts -t /opt/instrumentald/ start
User=nobody
Group=nogroup
TimeoutSec=60

[Install]
Expand Down
4 changes: 2 additions & 2 deletions test/integration/default/serverspec/instrumentald_spec.rb
Expand Up @@ -21,8 +21,8 @@

# "should be_running" doesn't seem to work, probably because the init.d script
# has an exit status of 0 when it is NOT running.
describe command('sudo /etc/init.d/instrumentald status') do
its(:stdout) { should match /"instrumentald" is running/ }
describe command('sudo /etc/init.d/instrumentald status; sudo systemctl status instrumentald') do
its(:stdout) { should match /("instrumentald" is running|Active: active \(running\))/ }
end

if details[:has_pid]
Expand Down

0 comments on commit 74f3b77

Please sign in to comment.