Open scripting opened 4 years ago
Hello @scripting! I'm a community engineer at Glitch.
We're working on some full fledged docs explaining the core of the service, but in the meantime, we've written up some draft docs.
I'll also save you a click and answer your more specific questions here:
the model for apps
we try to auto-detect the kind of app you're running. We currently support 4 app "types": Static, Node, Python, and Custom (everything else). If you have a package.json file, we assume Node, requirements.txt means Python, a glitch.json
file (explained in the above link) to set up something custom, and the absence of any of those files is a static site (the default).
how the filesystem works
In contrast to Heroku, we persist the filesystem. By default you get 200MB of storage, and boosted (paid) apps get 400MB. By default we track all files in the project using Git automatically, with the exception of any file you put in a folder called .data
or any filename listed in a .gitignore
file.
Can my app have an IP address?
We run multiple projects on the same host, so unfortunately you can't currently have a dedicated IP address.
How do I know what port to use
There's an environment variable named PORT
that contains the correct port to use. if you're using node, it would be accessed by getting process.env.PORT
.
I have succeeded at connecting to my app over HTTP but it comes embedded in something they constructed.
If an app hasn't started yet, we show an interstitial loading screen while we wake it up. If you boost an app, it will stay awake and you won't see that screen.
Now how do I strip it down so it works for its new intended purpose?
You can both import from GitHub and export back there, and if you want a more powerful editor we offer a Visual Studio Code plugin that lets you live edit from there. You can also open up the terminal (in the tools menu) and poke around, move/reorganize files, and do general linux-y things.
Thanks for giving the product a shot, and I'd be happy to answer more questions if you have them!
@potch -- thanks for the note. Very helpful.
I'll give it another try this morning. I had guessed at some of those things, such as process.env.PORT. And I did try the console and was very pleased to see that I have a folder that contains all the app files. Makes total sense.
Here's another question about the file system. I use AWS in my apps, primarily for S3 storage. They require you to store your credentials in a file in a sub-directory of your home directory.
The AWS CLI stores the credentials that you specify with aws configure in a local file named credentials, in a folder named .aws in your home directory.
On first examination it appears that I just have the one folder for each Glitch app, and there is no concept of a home directory.
@potch -- I've set up a simple test. Created a new Node project from your example app using Express as the web server shell. As I understand, it's URL is this:
https://glitch.com/~heliotrope-boiled-flyingfish
But it seems to be embedding it in the page viewer. How do I get it to just show me what the app itself displays? Do I have to upgrade to do that?
Also is there any way to map a sub-domain to it, or do I have to set up a server outside of Glitch to delegate requests?
@scripting
it appears that I just have the one folder for each Glitch app, and there is no concept of a home directory.
That is correct, each app lives in a /app
directory. However, that is considered the $HOME
directory for the environment, so /app/.aws
may work.
How do I get it to just show me what the app itself displays? Do I have to upgrade to do that?
No need to upgrade! You can click the "show" button on that page to be taken to the un-framed view for any app. Or, if you know the name of the project you can go to name-of-project.glitch.me
to see the same. Requests to that URL will go straight to your project with no middle processing.
Ohhh that's very good! I had assumed there was no subdomain. So I should be able to create a CNAME that points to my running project. Glad I asked. ;-)
We have lift-off.
Looks great, Dave! We're working to make the domain mapping stuff better (We had a first implementation but it wasn't great, so we wanna clean it up. And I bet Hover will be among the first we plug into.) but it's awesome to see you digging in. :)
@anildash & @potch -- I'm getting somewhere.
http://scripting.com/2020/04/17/141010.html?title=glitchDay3
It's a nice system. As I say in the post it's taking some getting used to.
Not sure where I'm going next, but I have landed on the island and can now build a nice tent, not sure what it would do.
@anildash -- I'm not sure there's much you need to do re domains than what you now do, unless you add the ability to get an IP address for an app. And Hover should work fine as-is.
One thing I would be interested in doing is have different apps share a file system. Can they??
Not sure where I'm going next, but I have landed on the island and can now build a nice tent, not sure what it would do.
Sounds a lot like my children currently playing "Animal Crossing™: New Horizons". Ah.
@jystervinou -- heh you know that was not an accident. :-)
I just did some more work and have more questions. I will search for them, so if they're easy to find I will find them.
Okay so I decided what my next step would be in my exploration of Glitch, get PagePark running there. And I did, and it took about five minutes. I keep trying to get Glitch to put up some resistance, but it doesn't. It really does run Node code, unmodified. When I get it working so quickly I'm dazed and need to retreat a bit and think some more as if I had hit obstacle after obstacle.
Here's the server: pagepark.glitch.me.
I just put a random OPML file there, and it just worked, as it should.
I lied. I did have to make a small mod. After reading the config.json file, I had to add a check to see if process.env.PORT was defined, and if so use that port, instead of the default port. That's how Glitch tells you what port to run on, same way Heroku does. I will add that to the PagePark distribution so it'll run without mods.
Okay so now I know what I want to do next. Find out if they have an API so I can use my own editor to write for this site. And all of a sudden I will have something useful that is shareable. Not bad.
So do they have an API? That's the next thing to look into.
Also I wonder if there's a way to have it reload from the GitHub repo automatically?
A glitch in Glitch -- when I reload the project from GitHub it wipes out all other files and directories. That means effectively you can't update from GitHub once you've started running the app.
BTW, I just realized of course I don't need Glitch to have an API, I can create my own.
I tried something on Glitch that I thought might work, but didn't. I created a CNAME for pagepark.glitch.me, thinking it would find its way to the app, but it didn't.
I'm guessing this is the feature you all were talking about. It would be a nice pref to have, maybe in the paying version, to say this CNAME should map to this app.
Just checking in, it's been a few months -- wondering what's new with Glitch, esp in re the GitHub integration.
Here's the post this is linked to.
Just trying out Glitch, very interesting system, looks like what I hoped Heroku would be, esp that now they have a way to run real server apps (no limits). $10 a month. Certainly worth checking out now as more than a curiosity.
Is there a simple no-frills doc that explains the model for apps. How the filesystem works, how to access an app over HTTP. Can my app have an IP address? How do I know what port to use (port 80 gets me an error). I have succeeded at connecting to my app over HTTP but it comes embedded in something they constructed. Obviously this won't work for serving my non-experimental apps.
I understand it's set up for newbies, that's cool. Now how do I strip it down so it works for its new intended purpose?
I know I've asked some of these questions before, btw -- but I'm approaching it now in a different way.