diff --git a/roles/mastodon-systemd/files/mastodon-sidekiq.service b/roles/mastodon-systemd/files/mastodon-sidekiq.service new file mode 100644 index 0000000..7d1e3d4 --- /dev/null +++ b/roles/mastodon-systemd/files/mastodon-sidekiq.service @@ -0,0 +1,16 @@ +[Unit] +Description=mastodon-sidekiq +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="RAILS_ENV=production" +Environment="DB_POOL=5" +ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/roles/mastodon-systemd/files/mastodon-streaming.service b/roles/mastodon-systemd/files/mastodon-streaming.service new file mode 100644 index 0000000..72be21b --- /dev/null +++ b/roles/mastodon-systemd/files/mastodon-streaming.service @@ -0,0 +1,16 @@ +[Unit] +Description=mastodon-streaming +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="NODE_ENV=production" +Environment="PORT=4000" +ExecStart=/usr/bin/npm run start +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/roles/mastodon-systemd/files/mastodon-web.service b/roles/mastodon-systemd/files/mastodon-web.service new file mode 100644 index 0000000..30fcbec --- /dev/null +++ b/roles/mastodon-systemd/files/mastodon-web.service @@ -0,0 +1,17 @@ +[Unit] +Description=mastodon-web +After=network.target + +[Service] +Type=simple +User=mastodon +WorkingDirectory=/home/mastodon/live +Environment="RAILS_ENV=production" +Environment="PORT=3000" +ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb +ExecReload=/bin/kill -SIGUSR1 $MAINPID +TimeoutSec=15 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/roles/mastodon-systemd/tasks/main.yml b/roles/mastodon-systemd/tasks/main.yml new file mode 100644 index 0000000..1d66103 --- /dev/null +++ b/roles/mastodon-systemd/tasks/main.yml @@ -0,0 +1,15 @@ +--- +# This role copies over various Mastodon service files and enables them + +- name: Copy Mastodon systemd service files + copy: src={{ item }} dest=/etc/systemd/system/{{ item }} backup=yes + with_items: + - mastodon-sidekiq.service + - mastodon-streaming.service + - mastodon-web.service +- name: Enable Mastodon systemd services + systemd: name={{ item }} enabled=yes + with_items: + - mastodon-sidekiq + - mastodon-streaming + - mastodon-web diff --git a/site.yml b/site.yml index 6e18e1b..3bcd72e 100644 --- a/site.yml +++ b/site.yml @@ -8,3 +8,5 @@ - mastodon-postgresql - mastodon-redis - mastodon-nginx + - mastodon-systemd +