threefoldtecharchive / jumpscaleX_threebot

Apache License 2.0
0 stars 3 forks source link

Create packages for our websites #25

Closed rkhamis closed 4 years ago

rkhamis commented 5 years ago

Follow docs here: https://github.com/threefoldtech/jumpscaleX_core/tree/development/JumpscaleCore/servers/threebot#packages

to create packages for all our websites

rkhamis commented 5 years ago

@Pishoy please create a list of all the websites we need to package and keep this storycard updated with progress

Pishoy commented 5 years ago
Pishoy commented 5 years ago

verified 1 - install jumpscaleX 2 - if website was already running Kill ALL tmux running servers clean bcdb kosmos 'j.data.bcdb.destroy_all()' remove old servers config rm -rf /sandbox/cfg/nginx/default_openresty_threebot/servers/* 3 - git clone webiste repo in /var/www/threefold_tech 4 - create you package file packgae.py in dir /sandbox/code/github/threefoldtech/jumpscaleX_threebot/ThreeBotPackages/threefold_tech as below

from Jumpscale import j

class Package(j.baseclasses.threebot_package):
    def _init(self, **kwargs):
        if "branch" in kwargs.keys():
            self.branch = kwargs["branch"]
        else:
            self.branch = "master"

    def prepare(self):
        """
        is called at install time
        :return:
        """
        server = self.openresty
        server.install(reset=True)
        server.configure()
        website = server.websites.get("threefold_tech")
        website.ssl = True
        website.port = 443
        locations = website.locations.get("main")
        static_location = locations.locations_static.new()
        static_location.name = "static"
        static_location.path_url = "/"
        static_location.path_location = f"/var/www/threefold_tech"
        static_location.use_jumpscale_weblibs = True
        website.domain = 'threefold_tech.grid.tf'
        website.path = '/var/www/threefold_tech'
        locations.configure()
        website.configure()

    def start(self):
        """
        called when the 3bot starts
        :return:
        """
        self.prepare()

    def stop(self):
        """
        called when the 3bot stops
        :return:
        """
        pass

    def uninstall(self):
        """
        called when the package is no longer needed and will be removed from the threebot
        :return:
        """
        pass

5 - open new session and load ur package

kosmos -p

j.tools.threebot_packages.get('mythreefold_tech',path='/sandbox/code/github/threefoldtech/jumpscaleX_threebot/ThreeBotPackages/threefold_tech') 

j.servers.threebot.default.start(web=True, ssl=True)
rkhamis commented 5 years ago

@Pishoy this task is actually about creating the website packages, not just verifying that the packages work.

Pishoy commented 5 years ago

waiting https://github.com/threefoldtech/jumpscaleX_threebot/issues/33

Pishoy commented 5 years ago

all websites are done, added package.py in their website repo and tested

PeterNashaat commented 4 years ago

1 - install jumpscaleX 2 - if website was already running

Kill ALL tmux running servers

clean bcdb

kosmos 'j.data.bcdb.destroy_all()' or bcdb delete --all

important dirs : /sandbox/cfg/nginx/default_openresty_threebot/servers/ has all websites conf file

3 - create your package file package.py and package.toml in website repo

package.py example of enertia website > change enertia to the name of your website

from Jumpscale import j

class Package(j.baseclasses.threebot_package):

    def start(self):
        server = self.openresty
        server.configure()
        for port in [80, 443]:
            website = server.get_from_port(port)
            website.domain = "UR_DOMAIN"
            locations = website.locations.get(f"enertia_locations_{port}")

            website_location = locations.locations_static.new()
            website_location.name = "enertiawebsite"
            website_location.path_url = "/"
            fullpath = j.sal.fs.joinPaths(self.package_root, "html/")
            website_location.path_location = fullpath

            locations.configure()
            website.configure()
            website.save()

package.toml example file of enertai website

[source]
name = "enertiaio"
description = "enertiaio website"
threebot = "threefold"
version = "1.0.0"

then move all website files in directory html .

From Jumpscale machine do :

JSX> cl = j.servers.threebot.local_start_zerobot(background=False)                                                    
MARK THREEBOT IS STARTING
JSX> cl = j.clients.gedis.get("abc", port=8901, package_name="zerobot.packagemanager")                                
JSX> cl.actors.package_manager.package_add(git_url="https://github.com/PeterNashaat/www_enertia_io")                       

image

PeterNashaat commented 4 years ago

Websites need to have Package.py and package.toml files for now :

First create new branch 3bot and then add files in it and new html directory contains all website files

Pishoy commented 4 years ago

3bot.org and incubaid.com has been modified and tested, also threefold.love and threefold.tech tested