FlamesRunner / natCP

A free open source OpenVZ panel.
GNU General Public License v3.0
16 stars 12 forks source link

Refactor code #6

Open FlamesRunner opened 6 years ago

FlamesRunner commented 6 years ago

Yes, I know the code is a pile of spaghetti.

If your OCD is bugging you, and you have a good understanding of how to fix it, be my guest, and I'll add you to the contributor list on the front page.

Thanks!

mikebywater commented 6 years ago

I would probably look at starting with composer for auto loading classes and pulling in any dependencies then look at

I think a framework would really help but just adding the above and making it a bit more MVC would be good. I would also write a few unit tests to check I am not breaking anything as I go

Happy to have a go but would not want to take it in a direction you don’t want to go

FlamesRunner commented 6 years ago

Hey Mike,

Hope you're having a great day.

First off, let me address composer/framework issue: I wrote the base of the system while I wasn't using any sort of framework (e.g Laravel) as a rather terrible programmer at the time. Not the best of things to do IMO.

It'd likely require a rewrite really. It depends on what you're comfortable with, and I'll see what we can do from there.

Thanks again, Andrew

mikebywater commented 6 years ago

Hi mate

Laravel is my framework of choice however I agree it would be a significant amount of work. I fancy having a go and would commit a decent amount of time to it but I would probably have a fair few questions about the existing code base so if you think it’s too much work we could be less ambitious.

Cheers

Mike

FlamesRunner commented 6 years ago

Hey,

Feel free to ask any questions. I'll be happy to answer them.

Thanks again, Andrew

mikebywater commented 6 years ago

Should we create a v2 branch or something and I could submit PR to that for you to review ?

FlamesRunner commented 6 years ago

Sounds great. Technically, the panel hasn't yet reached version 1 persay, and I think it's a good idea to move it up to the next major version number.

So yeah, perhaps a release branch is an order.

mikebywater commented 6 years ago

Do you want to create a branch for this then and I will submit PR's for you merge into that branch?

I am just setting up a development environment for the work so should be ready to start tonight

FlamesRunner commented 6 years ago

I've created a development branch (called "development", located at https://github.com/FlamesRunner/natCP/tree/development) and you may use that. Any updates to the development branch, once you're ready for it to be tested, push it to the staging branch and I'll do some testing. You're free to help out on that as well.

Then, once everything is tested, it'll be merged with the master branch.

Once again, thanks for your help!

mikebywater commented 6 years ago

No problem. Having a bit of trouble getting set up at the moment. Have you ran openVZ as a vagrant box? What is your current setup for development?

FlamesRunner commented 6 years ago

The way I set up my development environment was with VirtualBox, installed with CentOS 6 x86_64. Then, I'd install the guest additions, and create a snapshot from there.

Depending on which you'd like to setup, the instructions will vary.

If you want to set up a slave server, use the installer from the slave/slaveInstall.sh. You can paste the following commands:

cd /tmp && wget https://raw.githubusercontent.com/FlamesRunner/natCP/master/slave/slaveInstall.sh
bash slaveInstall.sh

You can leave the system for the time being and the installation will be completed. Updating is a little weird; you need to download the contents of slave/, excluding slaveInstall.sh, change the permissions to 755 and move them to /sbin.

The host node is much easier to work with, as updating it simply requires you to unzip the contents of the web/ directory into the web server (which, at the moment, is using NGINX, PHP5 and MySQL.)

Hope this helps!

FlamesRunner commented 6 years ago

I've given you access to the development branch, and you're now a collaborator. Any issues, just create a ticket and I'll answer them as needed. Reviews are required to merge to staging and master branches.

Once again, thank you for your help.

mikebywater commented 6 years ago

Perfect. I am nearly sorted I have webapp working in one VM without any major issues and (I think) I have the slave node running properly in another VM in virtualbox. However I just need to work out how to add an ip to the slave vm that i can access from the webapp. Is this how you are set up?

FlamesRunner commented 6 years ago

Yes it is. Depending on whether you used Virtualbox, you can create an internal network. In the VM settings tab, go to the network section, click adapter 2 and set the mode to "Internal network."

Do this for both VMs, then, copy down the IP from the slave node and add it to the host.

That should be it.

mikebywater commented 6 years ago

OK I have my master VM 192.168.10.10 and the slave VM 192.168.10.11 both can ping each other. I have copied the slave access key. I have gone into admin/addNode.php and entered the ip and access key but get the "Error: Node cannot be added, because either the access key is invalid and/or the node does not have natCP installed" how do I validate that the slave is operating correctly?

FlamesRunner commented 6 years ago

To verify whether the slave is working properly, SSH to remote@192.168.10.11 with the access key.

If this doesn't work, stop here, and generate a 32 character string to replace the password with the slave user.

If it does work, there's likely a PHP dependency that wasn't installed. Check the error logs for more information

Thanks again, Andrew

mikebywater commented 6 years ago

Ok I am up and running thanks very much. I was being daft the host was rejecting password ssh as I usually only set up public key. I think I can get the basics working in Laravel tonight. Auth, user management and the node add. I think I would then be stuck, I will get that bit done and pushed to develop. I will maintain the current db structure for ease of upgrade.