I followed a guide from https://freedif.org/how-to-install-sharetribe-for-ubuntu-16-04 and it works like a charm.
So basically you have to create three files (don’t forget to change the directory to your Sharetribe project (the code below using /home/ubuntu/sharetribe )
File 1:
sudo nano /etc/systemd/system/sharetribe.service
and paste:
[Service]
WorkingDirectory=/home/ubuntu/sharetribe
ExecStart=/bin/bash -lc 'source /home/ubuntu/.profile && source /home/ubuntu/.rvm/scripts/rvm && bundle exec rake ts:index && bundle exec rake ts:start'
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=sharetri
User=ubuntu
Group=ubuntu
Environment=RAILS_ENV=production
[Install]
WantedBy=multi-user.target
File 2:
sudo nano /etc/systemd/system/sharetribe2.service
and paste:
[Service]
WorkingDirectory=/home/ubuntu/sharetribe
ExecStart=/bin/bash -lc 'source /home/ubuntu/.profile && source /home/ubuntu/.rvm/scripts/rvm && bundle exec rake jobs:work'
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=sharetri
User=ubuntu
Group=ubuntu
Environment=RAILS_ENV=production NODE_ENV=production
[Install]
WantedBy=multi-user.target
File 3:
sudo nano /etc/systemd/system/sharetribe3.service
and paste:
[Service]
WorkingDirectory=/home/ubuntu/sharetribe
ExecStart=/bin/bash -lc 'source /home/ubuntu/.rvm/scripts/rvm && bundle exec rails server -e production'
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=sharetri2
User=ubuntu
Group=ubuntu
[Install]
WantedBy=multi-user.target
Finally, enable the scripts
sudo systemctl enable sharetribe
sudo systemctl enable sharetribe2
sudo systemctl enable sharetribe3
reload the systemd daemon
sudo systemctl daemon-reload
Start them
sudo systemctl start sharetribe
sudo systemctl start sharetribe2
sudo systemctl start sharetribe3
Once again, thanks to @karibu and @phatza for helping me out at https://www.sharetribe.com/community/t/how-to-run-sharetribe-in-background/281/12