Part numbering system for Epic Robotz
Epic Robotz has a CAD subteam whose job it is to design parts in Solidworks. This usually requires many interacting parts. Each part is given a "Part Number" to keep track of the hundreds if not thousands of parts that need to be drawn and manufactured in a typical season.
The Part Numbering System (PNSys) is a web based server that assigns part numbers for the CAD team. The software in this directory is everything needed to build and maintain this web server.
Currently the server that runs the PNSys software is hosted by Digital Ocean. To gain access to the Digital Ocean dashboard you will need access rights to the team account "EpicRobots". At the Digital Ocean dashboard, you can shut down the server, and restart it. Also, at the dashboard, you can set up DNS records that will cause different domain names to be directed to our server. Once the server is up and runing, you don't normally need to do this.
Once the server is running, (and most of the time it is), you can use SSH to access it's console -- and issue linux commands to configure and control it. To access it with SSH, you will need to generate your own SSH keys, and then have Mr. Brandon install those keys on the server. On Mac and Linux this is easy -- just google it. For Windows, install "Ubuntu for Windows" and then use that as a linux console, and generate your keys there.
Once the proper keys are installed, use the following command to gain access:
The IP address of our server is 206.189.166.169 which was issued to us by Digital Ocean.
Note that "dal" is the account where the PNSys software is currently stored. As a
shortcut, you can add the 206.189.166.169 to your /etc/hosts file under the name pnsys, and
do this instead:
ssh dal@pnsys
(For the remainder of this readme, pysys is the alias used for our server IP address.)
Currently we have two accounts on GoDaddy where our team maintains our domain names. The first accout is account # 88967949, maintained by Ginger DeVries. The second is account # 92651902 maintaind by Dal Brandon. We are currently using "epicteam.org" under the second account. Go Daddy points that to the Digital Ocean's DNS servers.
At the Digital Ocean's DNS, we have installed an "A" record that points "pn.epicteam.org" to our 206.189.166.169 server. Therefore, currently the PNSys website is at "pn.epicteam.org"
The PNSys uses the following components:
Ubuntu 16.04 -- The operating system. Should be supported until 2021
Go -- The language that the server code is writen in
Javascript -- Much of the client software is in Javascript
HTML, CSS -- Normal HTML and CSS stuff for web sites
MySql -- For the database
Git -- For code maitance.
Our Digital Domain "Droplet" for the PNSys system has all these components installed. For development, you should install all theses to your local machine. Also you will need an editor, such as notepad++ or sublime.
The GO source code calls for many "packages" to be installed. Simply running "go get" will install everything needed after you get the initial respository from git.
All code for the server is stored at git hub. It is a Go project, so the following directory sturcture is used:
~/dev -- the 'root' of the developement code
~/dev/bin -- where the executibles of "go build" are deployed (not used)
~/dev/pkg -- used by golang to maintain go packages
~/dev/src -- where custom go source is located
~/dev/src/epic -- Where the source for the PNSys SERVER is located.
The is the root for the PNSys repository from git.
~/dev/src/epic/lib... -- Place where source for go librarys are located
~/dev/src/epic/pnserver... -- Place where the server binary exists, and is run from
~/dev/src/epic/pnserver/logs -- Contains log files generated by pnserver
~/dev/src/epic/pnserver/static -- Contains static files servered by pnserver (css, js, img, template, ...)
On the actual pnsys machine, the 'dal' account is used, so all these start with /home/dal/dev...
We use MySql to store the data. To access mysql, do:
mysql -u root -p
That is, we use the root account. The password is avaliable from Mr. Brandon.
Assuming that you have installed all the required software, log into pnsys, and start here.
-
First use git pull to get all the latest software from git:
cd /home/dal/dev/src/epic git pull
-
Next, build the server:
cd /home/dal/dev/src/epic/pnserver go build
-
Next, edit the config.txt file. There is a config_example.txt file with comments to help with this. Store the config.txt file in the same directory as where the server binary will be run from. This is normally /home/dal/dev/src/epic/pnserver.
-
Create the mysql database:
cd /home/dal/dev/src/epic/pnserver/pnsql mysql -u root -p
At this point, you should be in mysql. Now to create and do an inital database load, do:
source CreateDatabase.sql; source LoadDatabase.sql;
-
Start the server on the command line to gain access to the console:
cd /home/dal/dev/src/epic/pnserver sudo ./pnserver
-
At this point the server should be running, but not in the background. This is so we can be sure it runs properly in the current environment and to issue other commands to initalize the database.
-
Issues the following commands to initalize the database with parts that were created before PNSys existed.
>import pnsql/oldepicparts.csv type=epic >import pnsql/oldsupplierparts.csv type=supplier
These command may take 30-60 seconds each. The output is buffered, so you will get a blast when they are done. There will be a few minor errors becuase some old parts numbers are not unique.
-
Start the server for real. First, exit with "exit", then do:
sudo ./pnrun
This runs a script that will start up pnserver in the background, and detact it from the terminal. You can now log out, and the server will continue to run.
If you used pnrun to start the server, and it is running in the background, you must stop it, to make code changes and restart. To stop it, finds its PID number with:
ps -A | grep pnserver
Then kill it with:
sudo kill -9 nnnn
where nnn is the PID number.
Make your code changes, rebuild it, and this start it again like this:
cd ~/dev/src/epic
git status
git add ...
git commit -m "your comments on what you did here."
git pull --rebase
git push
cd ~/dev/src/epic/pnserver
go build
sudo ./runpn
The pnserver generates log files. These are stored in /home/dal/dev/src/epic/pnserver/logs. There is one log file per day, named like Log_YY-MM-DD.txt.
To backup the MySql Database, log into pnsys, and do:
cd /home/dal/dev/src/epic/pnserver/pnsql
mysqldump -u root -p PnSysData > backupfile.sql
You should name the backup file like so: PnSys_Backup_YYMMDD.sql, where YYMMDD stand for for the current date. Once this file is written, copy it to some off server location (such as GitHub). In an emergency it can be used to regenrate the entire database.
If you have any questions, feel free to talk to Mr. Brandon.