twingly/capistrano-twingly

Initial deploy for systemd fails since #47

Closed this issue · 0 comments

When deploying an app for the first time there is no systemd target to stop at

on roles(:systemd) do
sudo :systemctl, "stop #{fetch(:application)}.target"
within current_path do
sudo fetch(:chruby_exec), "#{fetch(:chruby_ruby)} -- #{fetch(:bundle_binstubs)}/foreman export systemd /etc/systemd/system -a #{fetch(:application)} -u \`whoami\` -l #{shared_path}/log"
end
sudo :systemctl, "daemon-reload"
end
which makes the task fail with the following error:

sudo stderr: Failed to stop twingly-test.target: Unit twingly-test.target not loaded.

We should only run systemctl stop if the target can be found (ie. the application has been deployed before). I'm sure there is a good way to determine if that is true.

This bug was introducced in #47