Create systemd diaspora*
Updated for 2021 for diaspora version 0.7.14.0
Assumptions
- You are using a dedicated user to launch diaspora scripts named "diaspora"
- Your home directory is "/home/diaspora"
Steps
- Change directory to where you would normally manually start your script.
cd /home/diaspora/diaspora
- Run the following two commands:
rvm current
/bin/bash -lc "rvm current"
- The output of both of these needs to match exactly for the service and target files to work properly!
diaspora@computer:~/diaspora$ rvm current
ruby-2.6.5@diaspora
diaspora@computer:~/diaspora$ /bin/bash -lc "rvm current"
ruby-2.6.5@diaspora
- Make sure you can manually run the following two commands and diaspora starts:
/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"
/bin/bash -lc "bin/bundle exec sidekiq"
- NOTE: to stop the above commands, hit Ctrl + C.
- If for any reason you cannot start these commands, your install of rvm probably isn't right (not in scope of this post).
- Change directory into where we will be storing the services
cd /etc/systemd/system/
- Create a target file that will call the diaspora unicorn and sidekiq service files
sudo nano diaspora.target
- Contents:
[Unit]
Description=diaspora\* social network
## Postgres section
#Wants=postgresql.service redis-server.service
#After=redis-server.service syslog.target network.target postgresql.service
## MySQL section
Wants=redis-server.service
After=redis-server.service syslog.target network.target mysqld.service
[Install]
WantedBy=multi-user.target
- NOTE: If you use postgresql, make sure to comment out the MySQL section, and uncomment the Postgres section.
- Create the diaspora web unicorn service file
sudo nano d-web.service
- Contents:
[Unit]
Description=diaspora\* social network (unicorn)
PartOf=diaspora.target
StopWhenUnneeded=true
[Service]
User=diaspora
WorkingDirectory=/home/diaspora/diaspora
PIDFile=/home/diaspora/diaspora/tmp/pids/web.pid
Environment=RAILS_ENV=production
ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
[Install]
WantedBy=diaspora.target
- Create the diaspora sidekiq service file
sudo nano d-side.service
- Contents:
[Unit]
Description=diaspora\* social network (sidekiq)
PartOf=diaspora.target
StopWhenUnneeded=true
[Service]
User=diaspora
WorkingDirectory=/home/diaspora/diaspora
PIDFile=/home/diaspora/diaspora/tmp/pids/sidekiq1.pid
Environment=RAILS_ENV=production
ExecStart=/bin/bash -lc "bin/bundle exec sidekiq"
Restart=always
[Install]
WantedBy=diaspora.target
- Reload systemd daemon
sudo systemctl daemon-reload
- Enable the newly created files
sudo systemctl diaspora.target d-web.service d-side.service
- Cross your fingers and start the diaspora services
sudo systemctl start diaspora.target
- CHECK TO MAKE SURE EVERYTHING IS WORKING
sudo systemctl status d-web
and sudo systemctl status d-side
- If everything went well, you should get:
diaspora@computer:/etc/systemd/system$ sudo systemctl status d-web
● d-web.service - diaspora\* social network (unicorn)
Loaded: loaded (/etc/systemd/system/d-web.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-01-21 11:22:17 CST; 10s ago
Main PID: 23443 (ruby)
Tasks: 9 (limit: 4915)
CGroup: /system.slice/d-web.service
├─23443 unicorn master -c config/unicorn.rb -E production
├─23806 unicorn worker[0] -c config/unicorn.rb -E production
├─23808 unicorn worker[1] -c config/unicorn.rb -E production
└─23810 unicorn worker[2] -c config/unicorn.rb -E production
Jan 21 11:22:17 computer systemd[1]: Started diaspora\* social network (unicorn).
Jan 21 11:22:18 computer bash[23443]: I, [2021-01-21T11:22:18.341946 #23443] INFO -- : Refreshing Gem list
Jan 21 11:22:20 computer bash[23443]: Rack::SSL is enabled
Jan 21 11:22:22 computer bash[23443]: I, [2021-01-21T11:22:22.655211 #23443] INFO -- : unlinking existing socket=/home/diaspora/diaspora/tmp/diaspora.sock
Jan 21 11:22:22 computer bash[23443]: I, [2021-01-21T11:22:22.655347 #23443] INFO -- : listening on addr=/home/diaspora/diaspora/tmp/diaspora.sock fd=10
Jan 21 11:22:22 computer bash[23443]: I, [2021-01-21T11:22:22.663995 #23806] INFO -- : worker=0 ready
Jan 21 11:22:22 computer bash[23443]: I, [2021-01-21T11:22:22.665690 #23443] INFO -- : master process ready
Jan 21 11:22:22 computer bash[23443]: I, [2021-01-21T11:22:22.666855 #23808] INFO -- : worker=1 ready
Jan 21 11:22:22 computer bash[23443]: I, [2021-01-21T11:22:22.670572 #23810] INFO -- : worker=2 ready
diaspora@computer:/etc/systemd/system$ sudo systemctl status d-side
● d-side.service - diaspora\* social network (sidekiq)
Loaded: loaded (/etc/systemd/system/d-side.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-01-21 11:22:17 CST; 32s ago
Main PID: 23444 (ruby)
Tasks: 12 (limit: 4915)
CGroup: /system.slice/d-side.service
└─23444 sidekiq 5.2.8 diaspora [0 of 5 busy]
Jan 21 11:22:17 computer systemd[1]: Started diaspora\* social network (sidekiq).
Jan 21 11:22:20 computer bash[23444]: Rack::SSL is enabled
- Navigate to your website, and you shouldn't have a 503 error!
tag cloud
#
diaspora #
admin #
podmin #
question #
help #
answer #
systemd #
systemctl #
service #
targetsources