Hi!
In this tutorial, I’ll show you how to run Houdini as a Service on Ubuntu 18.
Why?
Having houdini as a service makes it easier to start, stop, and restart it. It also lets you autostart it when your server starts up.
Prerequisites & Notes
- You’ve already installed Houdini Legacy on Ubuntu following the official tutorial.
- You are following the tutorial on a non-root user account with sudo privileges. Click here to learn how to make one
- Houdini is accessing the database using a MySQL/MariaDB account other than root. To make one, you can enter the MySQL commandline
sudo mysql
and run the following queries:-
CREATE USER 'Houdini'@'localhost' IDENTIFIED BY 'PASSWORD_HERE';
(Replace PASSWORD_HERE with a password. You can use this site to generate a password. Use a “Fort Knox” password and make sure it doesn’t have any'
s or;
s. GRANT ALL PRIVILEGES ON '*'.'Houdini' TO 'Houdini'@'localhost';
-
- In this tutorial, I use
vim
as my text editor. You can use whatever editor you want.- Basic tutorial how to use vim:
- When you open
vim
, pressI
to go into insert mode (contrary to the name, this is the normal mode where you can write stuff, erase stuff, etc like in notepad). - To save and exit, press
ESC
then write:x
and pressEnter
- When you open
- Basic tutorial how to use vim:
The Tutorial
Installation
- Create a user account that will run the Houdini service.
adduser houdini --disabled-password
- Move your Houdini installation to the new account’s home folder.
mkdir /home/houdini/h
mv ~/houdini/* /home/houdini/h
- Navigate to the new location and make a new folder called
service
, then navigate into it.
cd /home/houdini/h
mkdir service
cd service
- Make a new script called
start.sh
vim start.sh
- and paste the following code into it
#!/bin/bash
cd ~/h
python Login.py &
python World.py
- If you have more than one server, for example
World.py
andMarshmallow.py
, add lines to the script above but replaceWorld.py
with the other filename. Make sure every python line except the last one has a&
at the end, or else it won’t work. Like this:
#!/bin/bash
cd ~/h
python Login.py &
python World.py &
python Marshmallow.py
- Save and exit, then make the file executable
sudo chmod +x start.sh
- Navigate to
/etc/systemd/system
and make a file calledhoudini.service
:
cd /etc/systemd/system
sudo vim houdini.service
- Then paste the following code into it
[Unit]
Description=Club Penguin AS2 server written in Python.
Wants=mysqld.service
[Service]
User=houdini
WorkingDirectory=/home/houdini/h
ExecStart=/bin/bash /home/houdini/h/service/start.sh
Type=simple
- Save and exit.
- Now that we’re done, go back into
cd /home/houdini/h
then run these commands to give it ownership of the files.
sudo chown -R houdini:houdini /home/houdini/h
-
sudo chmod -R u=rw,g=rw,o=rw /home/houdini/h
Optional: Change permissions on the houdini folder so that other users can edit files too. This is so that you can change stuff without having tosudo su houdini
.
- Reload the systemctl daemon
systemctl daemon-reload
- Optionally, enable automatically starting the houdini service when the VPS/server starts
systemctl enable houdini.service
- Start Houdini to see if it works.
service houdini start
Usage
- To start Houdini, run
service houdini start
- To stop Houdini, run
service houdini stop
- To restart Houdini, run
service houdini restart
- To enable automatically starting when the server starts, run
systemctl enable houdini.service
- To disable automatically starting when the server starts, run
systemctl disable houdini.service
The End
If you need help or think I forgot something, PM me on discord at daniel11420#0069 or reply to this thread. Hope this helps someone. Thanks for reading.