Skip to main content
All pages in this manual

Running your project

The customer website

What this page is for: put the separate React storefront — the website your shoppers browse — on its own domain, next to the 6ammart admin site.

You need

  • Your website code, in one of two shapes:
  • the zip you downloaded from CodeCanyon (the "React user website" item), or
  • the git repository URL of your customer-website code — this is a second repository, not the admin one. If it is private, you can use either an access token or this server's own deploy key; the screen asks which and walks you through it, exactly as the admin app's install does.
  • A domain or subdomain for it, for example shop.example.com.
  • Your 6ammart admin app already installed and working.

The customer website is not an add-on nobody uses: it is how customers order from a browser rather than from the phone apps. A project can sell through the apps alone, and some do, but most people want both.

1. Deploy the website code

  1. Open the project's Deploys page (in the Project menu group).
  2. Find the Customer website section.
  3. Choose where the code comes from:
  • From a zip file — pick your CodeCanyon website zip. Upload the whole download if you like: it usually contains the site and a "changed files" folder for people upgrading by hand, and the panel takes the complete one and says in the log which it skipped. Use the website zip from the same CodeCanyon release as your admin app: when the zip says it is another release (its NEXT_PUBLIC_SITE_VERSION, for example 3.6 beside a 4.1 admin), the log's first step warns you by name. The deploy still goes on — the warning is there so a website that misbehaves afterwards has its reason in plain sight. If another job is running when the upload ends, the zip is kept and the build starts by itself when that job ends. A zip that cannot be used whatever the server is doing is refused as soon as its upload ends; nothing is kept for it.
  • From a git repository — paste the repository URL. The screen then asks how this server should read it:
  • HTTPS — with an access token. Leave the token blank for a public repository; paste one only if it is private.
  • SSH — with this server's deploy key. Nothing secret is stored here: the panel makes a key, you add it to the repository, and the server uses it from then on. This is the website's own key, separate from the admin app's, so the two repositories can use different keys.

Then press the install button: it checks the connection first. It answers in about a second — whether the server can read the repository, and which branches it has — so a wrong token is found now rather than several minutes into a build; when it fails the screen says why and stays where it is. Check the connection beside the box asks the same before you press it, and lets you pick the branch from the real list.

  1. Press the install button.

The job unpacks or downloads the code, installs its dependencies, builds the site, points it at this project's admin address and starts its service. On a small server the build takes several minutes and uses a lot of memory — this is the heaviest thing that ever runs on the machine, which is why the installer adds swap space on servers with little RAM. Watch the log; the last lines say the website is running.

Installing the packages has 30 minutes and the build 40, the same as a Node.js website's (stretched up to four times when the build has to run in swap). A step that is still running then — usually a package registry that stopped answering — is stopped, and the log says which one. The live website keeps serving the build it had; run the deploy again, and if it stops at the same place, the lines above it show what it was waiting for.

The build happens here, on your server. There is nothing to build on your own computer and no need for Node.js anywhere else — SixPanel installs the Node version the storefront needs as part of the server setup.

Later, a newer zip is uploaded the same way: the Customer website card offers Upload a newer website zip once a site was installed from one. Your settings survive; only the code is replaced. While another job is running, the button names the job it waits for, and the build starts by itself when that job ends — the zip is not uploaded twice. Leaving the page, or closing the tab, while it waits removes the kept zip.

Before the website exists

The moment you give the storefront a domain, that address gets a certificate and starts working — and until you have deployed the site, it serves a short page saying the shop is not open yet and pointing back at this step. That is normal. It disappears by itself the moment the storefront starts.

2. Give it a domain

  1. Open Domain & SSL (in the Project menu group).
  2. Find the Customer website section and press Add domain.
  3. If Cloudflare is connected, the panel creates the DNS record for you, proxied. Otherwise add an A record for that name at your DNS provider, pointing at this server's IP address — the page prints it for you.
  4. Press Re-check DNS until the name shows pointed.
  5. Press Get free SSL.

When you created the project from a single domain, this name was already suggested and registered for you — usually the domain itself, plus www.

3. Turn the website service on

  1. Open Advanced → the Services tab (in the Project menu group).
  2. In the Customer website card, turn it on.

The first deploy already starts the service, so this card is mostly for turning it off and on again later. Turning it on or off runs as a job: its log opens beside the card, and it waits its turn behind a deploy that is still running. The card also tells you when the website is one of the things your project still needs.

Over SSH, the same two actions:

sudo sixpanel service enable react
sudo sixpanel service disable react

disable only stops it now. It is not remembered: sixpanel service start all and the panel's own Services tab both bring it back. To turn it off for good, use the switch on that tab — the panel records that as your decision and never starts it again by itself.

How the website is started. When the start script in your website's package.json is the usual next start (with or without a port of its own), the panel starts Next.js directly: one process, and roughly 80 MB less memory per website than starting it through npm. Anything else is run through npm run start exactly as you wrote it — a custom server, a wrapper, settings in front of the command, a prestart or poststart script, a config block in package.json, a Node.js of its own installed with the website (the node package), or an .npmrc file in the website folder. The panel reads the script again at every deploy. If you change it by hand to something other than next start, restart the website from the Services tab once: from then on the panel runs your script through npm. A restart typed over SSH does not re-read it.

If a website ever fails to come up when started directly but runs under npm, the panel switches it back to npm run start by itself and keeps it there.

4. Update it later

Open Deploys → the Customer website section and press the update button. It pulls the newest code, rebuilds and restarts the site.

Your shop stays up while it builds. The new version is built in a separate folder beside the live one, and only a build that finished is switched in — the switch and the restart take a few seconds. The website runs as one process, so while that process restarts it is closed for a moment. Asked to stop, it takes no new visitors, finishes the pages it is answering and goes; then the new process opens. On our test server, in 300 restarts with visitors arriving the whole time, the old process was gone in about half a second (within 2.5 seconds in 299 of them) and the website was closed for a little under a second (1.2 seconds or less in nine restarts of ten).

A visitor who arrives in that moment waits and then gets the page from the new version, not an error page: while the process restarts, the panel holds the requests that find the website closed and hands each to the new process the moment it opens. On our test server, in 31 restarts and update go-lives of the untouched CodeCanyon website and of a customised one, all 105 visitors who arrived while the website was closed got the page (without the wait, 8 to 12 visitors per restart got the "not open yet" page). The wait is the closed moment plus the time the new process takes to build its first page: the longest was 5.4 seconds on the customised website and 13.4 seconds on the untouched one (in a restart whose old process took three seconds to stop). The job log says that visitors waited, and how long the longest wait was: from the moment a visitor's request arrived until the new version's answer began to come back, so a first page built cold is in the number. A connection the new version never answered is counted and said apart, never as answered. A request waits at most 30 seconds: if the new version has not opened by then, that request gets the "not open yet" page (HTTP 503), and the next visitor is held again and gets the page as soon as it opens.

The same holds for the restart after an address change or a new certificate, for Restart on the Services page (also when you press it while an update is going live: the visitors stay held until both restarts are over) and for the website of a staging copy. After Restart on the Services page, the message where you pressed it says how many connections were held and how long the longest wait was (or that nobody arrived, or why visitors could not be held); the same lines are in that service's Live logs, and Activity has one line for the restart. Waiting for the new process has a cost: Restart on the Services page answers once the website is open again and the visitors it held have started to get their page (at most 30 seconds more) — about three seconds on our test server, instead of under half a second — and an update's go-live takes about two seconds longer. When the panel, starting after an update, restarts the website because the update changed how it is started, the visitors are held the same way. Two restarts are not held: a restart over SSH (sudo sixpanel service restart react) and the restart of every service at the end of a panel update. A visitor in their closed moment gets the "not open yet" page, and the page itself on the next try.

Three things are outside the wait. A form or another request that changes something (a POST) which the old process had already been handed in the instant it stopped gets the "not open yet" page: nginx does not send such a request a second time, because the old process may have carried it out. A request that is held is sent to the new process once, never twice. If you press Restart again right after a restart, the new process may still be building the first pages for visitors who were held for it when it is asked to stop: those few (up to three per restart on our test server) get the "not open yet" page after a few seconds (4.5 to 7 seconds there), as visitors whose page was being built did before. And if the panel itself is stopped or restarted in those seconds, the wait ends with it: the requests waiting at that moment get the "not open yet" page, and the panel puts nginx's settings back the way they were before it ends.

Holding visitors makes nginx read its settings twice more per restart (once to start the wait, once to end it). nginx lets the connections it already has finish on the processes that had them, so a phone that keeps a live order tracking connection open is not cut off; those processes go away when their last such connection closes. Any other change that makes nginx read its settings (a new certificate, an address) does the same.

A stop never waits longer than ten seconds. A website that is still answering a visitor ten seconds after it was asked to stop is ended at that point, and the answer it was writing is lost: that is a page that takes longer than ten seconds to build (the one restart of the 300 that was not over in 2.5 seconds: a page was waiting for the shop's API), or — once — a website that was already running when the server was updated to this behaviour, the first time it is restarted afterwards (it then starts in the new way, and from its second restart on it goes at once). Its log on the Services page says "still answering visitors 10 s after it was asked to stop: ended now". Neither is reported as a crash, and no alert is sent for it. A website that is restarted again while it is still starting finishes starting first — a few seconds — and then goes. The first pages after a restart are slower than usual, because the new process builds each for the first time: on our test server the first one took about four seconds, the next ones a fraction of one.

If the build fails (a code error, or the server ran out of memory), nothing on the live website changes: it keeps serving the version it had, and the job log says why the build stopped. The failed step itself says the cause too — the reason the panel recognised, or the build's own last error lines — not just which program stopped. One cause it names by itself: a website zip whose src/firebase.js still holds the vendor's placeholder <API_KEY>, which Firebase refuses while the pages are built. Put your own Firebase web app settings (Firebase console → Project settings → Your apps → Web) into that file and deploy again.

A page somebody already has open keeps working. The scripts of the version you replaced stay on the server for 30 days beside the new ones, so a visitor who opened a page before the update and clicks on after it still gets the scripts that page asks for (a cart, a sign-in, a route change) instead of a broken page that needs a reload. The new version's files win where the names match, and anything older than 30 days is dropped.

If you set up push-to-deploy, a push to the website repository does this by itself. The website has its own webhook address and its own secret, separate from the admin app's — set it up once on the Deploys page. See Deploy and update your code.

5. Pages are kept for ten seconds

The customer website builds every page afresh each time somebody asks for it, and it can build only about a dozen a second. So the web server in front of it keeps a page for ten seconds and gives the same copy to the next visitor — but only to a visitor who is nobody in particular: not signed in, and whose browser sends nothing back with the request (no chosen language, no theme, no cart). The moment a browser sends such a choice, or a sign-in, that visitor's pages are built for them alone, every time, and are never kept.

So it helps where it matters most: somebody arriving for the first time, a search engine reading your pages, and a sudden crowd of either — thousands of requests a minute for one page reach the website as a few dozen. A shopper who has already used the website still has every page built for them alone — by a website that is no longer busy building the same page for every passer-by.

What that means for you:

  • A change you make in the 6ammart admin — a banner, a price, a new item — can take up to ten seconds to appear for people who are only browsing. When a page's ten seconds are over, the next visitor's request builds it again, and anybody who asks during that one build is given the previous copy instead of being made to wait — so on a busy website a page is at most ten seconds old, plus the moment it takes to build.
  • A page you remove, or one that stops being public (it now asks for a sign-in, or sends visitors elsewhere), has no new copy to take the old one's place. A visitor who asks for it alone gets the true answer at once. But while several ask at the same moment, all of them except one are still shown the old page, for up to a minute and forty seconds — never longer: every kept page is dropped for good at the end of its hundred seconds, whatever happened to it.
  • Each kept page is dropped once every hundred seconds and built again the first time somebody asks for it — each at its own moment, not all together, so on a busy website whose visitors are spread over many different pages those first builds come one after another and nobody queues behind them. Right after an Update or a Restart it is different: they empty the kept pages at once, the first builds do come together, and because the website builds one page at a time a page can take seconds instead of a fraction of one for a few seconds — for signed-in shoppers too.
  • A page the website itself marks as private (checkout, profile) is never kept, whoever asks for it. Neither is anything that is not an ordinary page: images and other files, and the website's own /api/ addresses, are passed straight through as before.
  • Update and Restart from the panel empty the kept pages at once, so nobody is shown a page from the version you just replaced. A restart over SSH (sudo sixpanel service restart react) does not; each kept page is built again by itself the first time somebody asks for it after its ten seconds.
  • If the website stops answering while it is still running (it hangs), people who are only browsing can go on being shown the kept pages until those are dropped — up to a minute and forty seconds — while a shopper who is signed in sees the fault at once. The Customer website line of Server → Health asks the website itself, never a kept page, so it shows the fault straight away. A monitoring service of your own that asks the way an anonymous visitor does can be that minute and forty seconds late.
  • A staging site never keeps pages — what you test is what runs.

See it yourself. Every page of the website answers with an X-Cache line:

It saysIt means
MISSbuilt just now — and kept for the next visitor, if it is a page that may be kept
HITthe kept copy — the website was not asked
EXPIREDthe copy was older than ten seconds, so the page was built again for this visitor — and kept for the next
UPDATINGthe copy was older than ten seconds and another visitor's request is building the new one right now — this visitor was given the previous copy instead of waiting
BYPASSbuilt for this visitor alone, and not kept
PASSthe last answer for this address was one the website does not let be kept (a sign-in page, a 404, a page marked no-store or private), so for the next ten seconds visitors of it go straight to the website instead of waiting their turn

From any computer, twice within ten seconds:


curl -sI https://shop.example.com/ | grep -i x-cache

The second answer says HIT. (About once in a hundred tries it says MISS again: a kept page starts afresh once every hundred seconds, and your two requests fell on either side of that page's moment. Ask a third time. The X-Cache-Slot line beside it is a number that changes at exactly that moment.) Your own browser usually shows BYPASS once you have used the website: it remembers your language and theme and sends them with every request.

A page that is never kept says MISS every time, and that is correct: checkout, profile and the other pages the website marks as private, and an address that does not exist.

How to check it worked

  • Open your website domain in a browser. You should see the storefront with a padlock in the address bar.
  • Domain & SSL shows the website name as secured.
  • Advanced → Services shows the customer website running.
  • sudo sixpanel service status react prints it as running.

If it went wrong

  • The build failed — read the job log on the Deploys page. A wrong branch name, a private repository the server cannot read, or a server that ran out of memory during the build are the usual causes. For the second one, see the read-access key in section 5 of Put your code in a git repository. Your live website is unaffected either way. For the third, the log opens the build with one build memory line: the memory it may use before it swaps (MemoryHigh), that it has no hard limit (MemoryMax none), the swap added for it, whether compressed swap (zswap) is on, and the heap, which is sized from those same numbers. Running the update again while the server is quieter often succeeds. When the build was stopped for memory, the log says so in one line before the job fails: which limit it met, the kernel's own counters, the least swap that was free, and what the panel plans for the next build. The kernel stops the build first, so the shop, its database and the panel keep running.
  • The domain shows the admin site, not the storefront — the domain was added under the wrong section. It must sit under Customer website on Domain & SSL.
  • The page is blank or shows an error — read its log on the project's Logs page, or over SSH:
  sudo sixpanel logs react -n 100
  • A change in the admin does not show on the website — wait ten seconds and reload. Pages are kept that long for visitors who are only browsing (see section 5 above). If it still shows the old content after that, it is not the kept pages: check that the change is saved in the admin.
  • The storefront still shows the old page after an update — wait ten seconds and reload: pages are kept that long (section 5 above). If it still shows the old version, open Deploys and read the website update's job log. A build that failed leaves the previous version serving, and the log says why it stopped.
  • The folder is not empty — the panel refuses to clone into a folder that already holds files but is not a git checkout. Ask support before clearing it.

More symptoms: see When something is broken.

Something unclear?Ask Tia