Automatic startup methods: Difference between revisions
No edit summary |
SuperTux88 (talk | contribs) (Replace unicorn with puma) |
||
(20 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
This page is for listing | This page is for listing methods to automatically start diaspora* when your server starts. | ||
== | = Recommended: systemd = | ||
Open the following location in your favorite text editor | |||
{{#tag:syntaxhighlight| | |||
/etc/systemd/system/diaspora.service | |||
|lang="bash"}} | |||
and paste | |||
{{#tag:syntaxhighlight| | |||
[Unit] | |||
Description=Diaspora social network | |||
After=network.target | |||
[Service] | |||
User=diaspora | |||
WorkingDirectory=/home/diaspora/diaspora | |||
ExecStart=/bin/bash -lc "script/server" | |||
Restart=always | |||
[Install] | |||
WantedBy=multi-user.target | |||
|lang="systemd"}} | |||
into it. | |||
When the file is saved, you can start your pod with | |||
{{#tag:syntaxhighlight| | |||
systemctl enable --now diaspora.service | |||
|lang="bash"}} | |||
The pod will automatically start again if you restart your server. | |||
= Alternatives = | |||
These are possible alternatives, use them only if you have a specific need. | |||
== systemd with individual services == | |||
This configuration is based on a forum post of Benjamin Neff [https://discourse.diasporafoundation.org/t/installing-diaspora-on-debian-9/790/5] | |||
<pre>cd /etc/systemd/system</pre> | |||
Create the following files with you preferred text editor e.g. ''nano'' | |||
'''diaspora.target''' | |||
<pre> | |||
[Unit] | |||
Description=Diaspora social network | |||
Wants=postgresql.service | |||
Wants=redis-server.service | |||
After=redis-server.service | |||
After=postgresql.service | |||
[Install] | |||
WantedBy=multi-user.target | |||
</pre> | |||
'''diaspora-web.service''' | |||
<pre> | |||
[Unit] | |||
Description=Diaspora social network (puma) | |||
PartOf=diaspora.target | |||
StopWhenUnneeded=true | |||
[Service] | |||
User=diaspora | |||
Environment=RAILS_ENV=production | |||
WorkingDirectory=/home/diaspora/diaspora | |||
PIDFile=/home/diaspora/diaspora/tmp/pids/web.pid | |||
ExecStart=/bin/bash -lc "bin/bundle exec puma -C config/puma.rb" | |||
ExecReload=/bin/bash -lc "bin/pumactl -F config/puma.rb restart" | |||
ExecStop=/bin/bash -lc "bin/pumactl -F config/puma.rb stop" | |||
Restart=always | |||
[Install] | |||
WantedBy=diaspora.target | |||
</pre> | |||
'''diaspora-sidekiq.service''' | |||
<pre> | |||
[Unit] | |||
Description=Diaspora social network (sidekiq) | |||
PartOf=diaspora.target | |||
StopWhenUnneeded=true | |||
[Service] | |||
User=diaspora | |||
Environment=RAILS_ENV=production | |||
WorkingDirectory=/home/diaspora/diaspora | |||
ExecStart=/bin/bash -lc "bin/bundle exec sidekiq" | |||
Restart=always | |||
[Install] | |||
WantedBy=diaspora.target | |||
</pre> | |||
Now you have to enable all of them | |||
<pre>systemctl enable diaspora.target diaspora-sidekiq.service diaspora-web.service</pre> | |||
Start all services with | |||
<pre>systemctl restart diaspora.target</pre> | |||
You can check if puma and sidekiq work with | |||
<pre> | |||
systemctl status diaspora-web.service | |||
systemctl status diaspora-sidekiq.service | |||
</pre> | |||
'''Hint:''' The path '''''/lib/systemd/system/''''' is for unit-files installed from the system, you can create user-created units in '''''/etc/systemd/system/'''''. Both locations work. | |||
==== Other sources ==== | |||
* [https://github.com/jhass/diaspora/blob/old_systemd/diaspora.service Old systemd unit starting script/server] | * [https://github.com/jhass/diaspora/blob/old_systemd/diaspora.service Old systemd unit starting script/server] | ||
* [https://github.com/jhass/diaspora/tree/systemd/systemd | * [https://github.com/jhass/diaspora/tree/systemd/systemd modular systemd units] (running chruby instead of RVM) | ||
== | == daemontools == | ||
* [https://github.com/jhass/diaspora/tree/daemontools/daemontools Unmaintained scripts to start foreman directly] | * [https://github.com/jhass/diaspora/tree/daemontools/daemontools Unmaintained scripts to start foreman directly] | ||
== | == god == | ||
* [https://github.com/despora/diaspora/blob/despora/script/diaspora.god Despora god config] | * [https://github.com/despora/diaspora/blob/despora/script/diaspora.god Despora god config] | ||
* [https://github.com/diasporg/diaspora/blob/master/script/diaspora.god diasp.org god config] | * [https://github.com/diasporg/diaspora/blob/master/script/diaspora.god diasp.org god config] | ||
[[Category:Technical]] |
Latest revision as of 23:39, 9 June 2024
This page is for listing methods to automatically start diaspora* when your server starts.
Recommended: systemd
Open the following location in your favorite text editor
/etc/systemd/system/diaspora.service
and paste
[Unit]
Description=Diaspora social network
After=network.target
[Service]
User=diaspora
WorkingDirectory=/home/diaspora/diaspora
ExecStart=/bin/bash -lc "script/server"
Restart=always
[Install]
WantedBy=multi-user.target
into it.
When the file is saved, you can start your pod with
systemctl enable --now diaspora.service
The pod will automatically start again if you restart your server.
Alternatives
These are possible alternatives, use them only if you have a specific need.
systemd with individual services
This configuration is based on a forum post of Benjamin Neff [1]
cd /etc/systemd/system
Create the following files with you preferred text editor e.g. nano
diaspora.target
[Unit] Description=Diaspora social network Wants=postgresql.service Wants=redis-server.service After=redis-server.service After=postgresql.service [Install] WantedBy=multi-user.target
diaspora-web.service
[Unit] Description=Diaspora social network (puma) PartOf=diaspora.target StopWhenUnneeded=true [Service] User=diaspora Environment=RAILS_ENV=production WorkingDirectory=/home/diaspora/diaspora PIDFile=/home/diaspora/diaspora/tmp/pids/web.pid ExecStart=/bin/bash -lc "bin/bundle exec puma -C config/puma.rb" ExecReload=/bin/bash -lc "bin/pumactl -F config/puma.rb restart" ExecStop=/bin/bash -lc "bin/pumactl -F config/puma.rb stop" Restart=always [Install] WantedBy=diaspora.target
diaspora-sidekiq.service
[Unit] Description=Diaspora social network (sidekiq) PartOf=diaspora.target StopWhenUnneeded=true [Service] User=diaspora Environment=RAILS_ENV=production WorkingDirectory=/home/diaspora/diaspora ExecStart=/bin/bash -lc "bin/bundle exec sidekiq" Restart=always [Install] WantedBy=diaspora.target
Now you have to enable all of them
systemctl enable diaspora.target diaspora-sidekiq.service diaspora-web.service
Start all services with
systemctl restart diaspora.target
You can check if puma and sidekiq work with
systemctl status diaspora-web.service systemctl status diaspora-sidekiq.service
Hint: The path /lib/systemd/system/ is for unit-files installed from the system, you can create user-created units in /etc/systemd/system/. Both locations work.
Other sources
- Old systemd unit starting script/server
- modular systemd units (running chruby instead of RVM)