- You are using a dedicated user to launch diaspora scripts named "diaspora"
- Your home directory is "/home/diaspora"
- 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-3.3.5@diaspora
diaspora@computer:~/diaspora$ /bin/bash -lc "rvm current"
ruby-3.3.5@diaspora
- Make sure you can manually run the following two commands and diaspora starts:
/bin/bash -lc "bin/bundle exec puma -C config/puma.rb"
/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 (puma)
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 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
- 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 enable 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
andsudo 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 (puma)
Loaded: loaded (/etc/systemd/system/d-web.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2024-10-14 10:02:27 CDT; 3h 13min ago
Main PID: 825413 (ruby)
Tasks: 8 (limit: 19776)
Memory: 329.4M
CGroup: /system.slice/d-web.service
└─825413 puma 6.4.2 (unix://tmp/diaspora.sock) [diaspora]
Oct 14 10:02:31 computer bash[825413]: Rack::SSL is enabled
Oct 14 10:02:34 computer bash[825413]: * Listening on unix://tmp/diaspora.sock
Oct 14 10:02:34 computer bash[825413]: Use Ctrl-C to stop
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 Mon 2024-10-14 10:02:27 CDT; 3h 16min ago
Main PID: 825412 (ruby)
Tasks: 18 (limit: 19776)
Memory: 661.3M
CGroup: /system.slice/d-side.service
└─825412 sidekiq 6.5.12 diaspora [0 of 10 busy]
- Navigate to your website, and you shouldn't have a 503 error!
#diaspora #admin #podmin #question #help #answer #systemd #systemctl #service #target