Running your own server

Grieg - the 'service server'

CSE doesn't run shared database or application servers - instead, we provide a platform that allows you to run and administer your own.

This lets you run the exact software you want, configured however you want - even software you develop yourself.

We currently do this via the special-purpose login server called Grieg.

Access to Grieg is restricted to specific users and students of a few specific courses; your supervisor can request access on your behalf if you need it.

When to use Grieg

Grieg is mainly used for long-running services (eg. days/weeks/months at a time).

If you only need to run your service while you're logged in, you should use a lab machine or the normal login servers instead.

Running services on Grieg

You can log into Grieg using SSH.

Please don't do your editing, compiling or other work on Grieg - it should only be used for actually running your service.

If you are happy to bind to an arbitrary port above 1024, you can just run your service from here, and connect to it on grieg.cse.unsw.edu.au:<portnum>.

However, since grieg is a shared server, popular port numbers such as 8080 are likely to be in use already.

If you need to use a specific port number, or one below 1024 (such as 80 or 443 for a webserver), you'll need a virtual network interface.

Getting a virtual network interface

Grieg has some kernel extensions that can allocate you a virtual network interface and hostname, reserved for you alone.

Not only does this guarantee that all ports are available to use, but you can bind privileged port numbers (below 1024) as well.

To use these, run the command priv srvr in your terminal while logged into Grieg.

This will do several things:

  • Create a new virtual interface for you (if none already exists), with its own IP address and hostname.
  • Bind any new processes launched from this shell to the virtual IP address.
  • Grant those processes the right to bind to port numbers under 1024.
  • Create a directory (if none already exists) on Grieg's local storage, under /srvr/<username> (eg. /srvr/z1234567).

The virtual IP will be in the range 149.171.*.*, and the hostname will be <username>.srvr.

The IP and hostname are only accessible within the CSE network; see below if you need an externally-accesible URL.

Remember that priv srvr needs to be run in every terminal connected to Grieg.

If you log out and reconnect, or open a second terminal onto it, you will need to run priv srvr to bind that shell to the virtual interface.

Web-accessible services

The hostname username.srvr (or the corresponding URL http://username.srvr/) only works inside the CSE network.

If you need to run an externally-accessible webserver, you have to run it on port 80, and then it will be available via http://username.srvr.cse.unsw.edu.au/.

This is only available on port 80, and only works for HTTP.

Make sure your web application generates links to http://username.srvr.cse.unsw.edu.au/, and not http://username.srvr/.

Automatically starting your service

We occasionally have to reboot grieg for maintenance.

If it's critical that your service be accessible at all times (eg. hosting the database for a public website), then you can arrange for it to be restarted whenever Grieg reboots.

To do this, use a @reboot directive in a crontab:

@reboot /path/to/your_startup_script

The script you specify will be run whenever the server starts up after a reboot.

Cron doesn't provide many environment variables, so your script should set any it needs for itself.

If your service needs to be run in a priv srvr environment, then your script should start with /usr/local/bin/priv srvr.

Your /srvr/ directory

The first time you run priv srvr, your /srvr/<username> directory will be created.

This directory is on a disk connected directly to Grieg, so it can handle a lot of I/O without slowing down the network

This is where you should store database files, or other files that will need a lot of server I/O.

It's shared over NFS, so the same path is available from all CSE servers and lab machines.

It's not a suitable location for source code, tarballs, or the server software itself.

Those things should live in your home directory instead.

If you still need more space in /srvr/, send mail to System Support, and we can look at increasing your quota there.

Last edited by jbc 13/07/2018

Tags for this page:

database, server, grieg, mysql, postgresql, apache