atomic web server threads

Share your advanced PureBasic knowledge/code with the community.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: atomic web server threads

Post by Caronte3D »

Good news! :D
I will test it next week.
Thanks! :wink:
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Version 3.0.9b1
Added SSL, Linux x64 and Windows x86 x64, should run on win7+
seems to be working ok, running here
https://atomicwebserver.com

code linked in 1st post
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: atomic web server threads

Post by HeX0R »

You've meant https://atomicwebserver.com/
(you need sharp glasses to see the difference :mrgreen: )
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

HeX0R wrote: Fri Apr 26, 2024 7:13 am You've meant https://atomicwebserver.com/
(you need sharp glasses to see the difference :mrgreen: )
thanks, yes I need glasses. 8)
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: atomic web server threads

Post by Caronte3D »

Image
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

It's almost there but still some bugs to track down.
User avatar
Caronte3D
Addict
Addict
Posts: 1355
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: atomic web server threads

Post by Caronte3D »

Yes, the fact that the sessionID cookie doesn't remove when the web browser is closed is a pain because you don't know if a request is on the same session or another one.

Anyway, the work you are doing is awesome and... you are very fast implementing needed features 8)
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Caronte3D wrote: Fri Apr 26, 2024 9:49 am Yes, the fact that the sessionID cookie doesn't remove when the web browser is closed is a pain because you don't know if a request is on the same session or another one.

Anyway, the work you are doing is awesome and... you are very fast implementing needed features 8)
I will try adding an absolute expires.
If a cookie is set without max-age or expires it will delete as soon as the connection is closed but currently I'm not honoring keep alive requests and will close a connection after 10 second idle which is more to do making sure I have no memory leaks. I will address it soon enough.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 772
Joined: Fri Dec 04, 2015 9:26 pm

Re: atomic web server threads

Post by skinkairewalker »

Amazing.
Image
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

added mutexs to tls.pbi
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: atomic web server threads

Post by jamirokwai »

Currently, I can't open pages locally on macOS. Will try again next week. Maybe, I need to change the host as written in the examples.

But: When starting any of the examples, it throws an error at line 485:

; MessageRequester(*Atomic_Server\Title, "Error: can't create the server (port " + *Atomic_Server\port + " in use ?)")

[09:20:04] Executable type: MacOSX - arm64 (64bit, Unicode, Thread)
[09:20:04] Executable started.
[09:20:04] [ERROR] Atomic_Web_Server3.pbi (Line: 485)
[09:20:04] [ERROR] NSWindow should only be instantiated on the main thread!
[09:20:06] The Program was killed.

Edit: Just downloaded the current version from GitHub, the NSWindow-error is gone for the moment.
Regards,
JamiroKwai
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

jamirokwai wrote: Sat Apr 27, 2024 8:22 am Currently, I can't open pages locally on macOS. Will try again next week. Maybe, I need to change the host as written in the examples.

But: When starting any of the examples, it throws an error at line 485:

; MessageRequester(*Atomic_Server\Title, "Error: can't create the server (port " + *Atomic_Server\port + " in use ?)")

[09:20:04] Executable type: MacOSX - arm64 (64bit, Unicode, Thread)
[09:20:04] Executable started.
[09:20:04] [ERROR] Atomic_Web_Server3.pbi (Line: 485)
[09:20:04] [ERROR] NSWindow should only be instantiated on the main thread!
[09:20:06] The Program was killed.

Edit: Just downloaded the current version from GitHub, the NSWindow-error is gone for the moment.
I had the same issue on linux and adding ./ to the paths fixed the issues but I may have missed adding the fixes as I'm working on two branches and the test site is different to the live site.
I will try and test it tomorrow on osx just need to get the lap top off the wife
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Version 3.0.10b1

Reverted to single threads per client as multiple request threads per client were getting into contention on linux and causing a high cpu load.
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

Version 3.1.0b1

Added the virtual file system, this is pretty much it feature wise and can now undergo refinements. The virtual file system will eventually be replaced with a streamlined version if and when time allows.

To use the virtual file system you just need to create a pack with a call to Atomic_Server_Create_Pack() with your www directory, then include the .ezp file in data section then recompile and you've got all your assets in a virtual file system so you can use it to host the content to a web gadget and distribute as a single executable with no dependencies.
example of use is in single_server_localhost.pb repo has prepacked site in the .ezp

Code: Select all

Global server1 = Atomic_Server_Init("atomic_webserver","./www/","127.0.0.1","",80,#PB_Network_IPv4,5000,@CBPostGet(),@CBPostGet()) 

Atomic_Server_Create_Pack(server1) ;use this to pack the www folder and then include the binary comment it out and recomplie    

Atomic_server_Set_PackAddress(server1,?Index,?EndIndex-?Index) ;set the pack address and size 

OpenConsole() 

If Atomic_Server_Start(server1,-1,1)  ;start server no window logs to console 
  Repeat 
  Until Input() = "quit"   ;type quit to exit 
  Atomic_Server_Exit(server1)
  CloseConsole()
EndIf 

DataSection 
  Index:
  IncludeBinary "./www.ezp"
  EndIndex:
EndDataSection 

User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: atomic web server threads

Post by idle »

bug fixes, it finally seems to be stable on linux had to widen the scope of mutexes in tls.pbi

Version 3.1.0b3 fixed close connection on no data received
Post Reply