Module 0330: Setting up a Power sandbox for the Master project

Tak Auyeung, Ph.D.

February 19, 2020

Contents

1 About this module
2 Backing up the project
 2.1 Back up the database tables
 2.2 Back up the source files
 2.3 Ask Tak to set up a port number for you
 2.4 Create your sandbox
  2.4.1 Choose a subfolder name
  2.4.2 Create the subfolder
  2.4.3 Edit the Mysql dump file
  2.4.4 Create all the new tables
  2.4.5 Create all the sandbox source files
3 Running your sandbox

1 About this module

2 Backing up the project

The first is to back up the project. This is done both to make sure there is a restore point, but also to generate the necessary files to clone the project.

2.1 Back up the database tables

All projects share the same database designhub, so we have to be careful when we modify tables. At this pointer, there are only two tables.

To back up just the tables necessary, use the following command on the command prompt after signing as designhub:

mysqldump -p designhub master_session master_people > /tmp/master.sql!

This creates a MySQL/MariaSQL dump file /tmp/master.sql.

2.2 Back up the source files

Run the following commands:

cd ~/master 
tar czvf /tmp/master.tar.gz *

This creates a back up archive that has all the related source files.

2.3 Ask Tak to set up a port number for you

Because Power, for the most part, uses Apache as the HTTP(S) server, setting up Express to work requires a little bit of Apache configuration magic. Ask Tak to set up a path and a port number for you, and Tak will reply with the URI path and the port number for you.

2.4 Create your sandbox

Now that you have all the backed up files, a URL path and a port number, you can set up your own sandbox.

2.4.1 Choose a subfolder name

I suggest just your last name plus first initial. For the rest of this discussion, we will use Jack Lee as the developer. This means the folder name is leej.

2.4.2 Create the subfolder

Create the subfolder directly in the home folder using the following command: mkdir ~/leej.

2.4.3 Edit the Mysql dump file

The sandbox includes your own tables. The idea is to replace the prefix master_ with leej_. In this example, you can certainly do it by hand using an editor. However, you can also use the following command: sed -i s/master_/leej_/g/tmp/master.sql.

2.4.4 Create all the new tables

Now you are ready to create new tables for your sandbox using the following command mysql -p designhub < /tmp/master.sql.

2.4.5 Create all the sandbox source files

Go to your newly created subfolder using cd ~/leej. Then expand all the files from the backup archive using tar xzvf /tmp/master.tar.gz.

Next, customize a few files. These files are “hidden” files because their names start with a period.

And there you have it!

3 Running your sandbox

To run your sandbox, do the following:

cd ~/leej # change to your directory 
node express.js # wont return to command prompt, control-C to stop

While express.js is running, use a browser to visit the URL that Tak gives you.