- 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-2.7.8@diaspora
diaspora@computer:~/diaspora$ /bin/bash -lc "rvm current"
ruby-2.7.8@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 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 (unicorn)
Loaded: loaded (/etc/systemd/system/d-web.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-07-07 09:33:59 CDT; 50s ago
Main PID: 101479 (ruby)
Tasks: 6 (limit: 17935)
Memory: 268.6M
CGroup: /system.slice/d-web.service
├─101479 unicorn master -c config/unicorn.rb -E production
├─101820 unicorn worker[0] -c config/unicorn.rb -E production
└─101822 unicorn worker[1] -c config/unicorn.rb -E production
Jul 07 09:33:59 dwdu systemd[1]: Started diaspora* social network (unicorn).
Jul 07 09:34:00 dwdu bash[101479]: I, [2023-07-07T09:34:00.083554 #101479] INFO -- : Refreshing Gem list
Jul 07 09:34:01 dwdu bash[101479]: Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!
Jul 07 09:34:01 dwdu bash[101479]: Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!
Jul 07 09:34:03 dwdu bash[101479]: Rack::SSL is enabled
Jul 07 09:34:05 dwdu bash[101479]: I, [2023-07-07T09:34:05.520983 #101479] INFO -- : unlinking existing socket=/home/diaspora/diaspora/tmp/diaspora.sock
Jul 07 09:34:05 dwdu bash[101479]: I, [2023-07-07T09:34:05.521100 #101479] INFO -- : listening on addr=/home/diaspora/diaspora/tmp/diaspora.sock fd=10
Jul 07 09:34:05 dwdu bash[101479]: I, [2023-07-07T09:34:05.530642 #101479] INFO -- : master process ready
Jul 07 09:34:05 dwdu bash[101820]: I, [2023-07-07T09:34:05.534093 #101820] INFO -- : worker=0 ready
Jul 07 09:34:05 dwdu bash[101822]: I, [2023-07-07T09:34:05.536925 #101822] INFO -- : worker=1 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 Fri 2023-07-07 09:33:59 CDT; 7min ago
Main PID: 101478 (ruby)
Tasks: 12 (limit: 17935)
Memory: 310.5M
CGroup: /system.slice/d-side.service
└─101478 sidekiq 6.5.1 diaspora [2 of 5 busy]
- Navigate to your website, and you shouldn't have a 503 error!
#diaspora #admin #podmin #question #help #answer #systemd #systemctl #service #target