ThomasTJdev / nim_websitecreator

Nim fullstack website framework - deploy a website within minutes
https://nimwc.org
MIT License
176 stars 7 forks source link

`-d:demo` does only reset DB 1 time #69

Closed ThomasTJdev closed 5 years ago

ThomasTJdev commented 5 years ago

The resetDB() is missing a loop which means, that the DB is only reset 1 time. A while loop is needed:

https://github.com/ThomasTJdev/nim_websitecreator/blob/8e9a96a431b8baa01d179276d14eb38ba14354f9/nimwcpkg/nimwc_main.nim#L444-L454

juancarlospaco commented 5 years ago

The latest Firejail config allows a timeout on Hours, from 1 to 99 Hours, it works, maybe we can just delete all that code, and use firejail to restart every 1 Hour and do a wipe.

Like Reset at start when defined(demo), then Firejails restarts every 60 minutes, no while loop needed.

Nim:

when defined(demo):
  exec(db, sql"DELETE FROM blog") 
  createStandardData(db) 

On config.cfg:

[firejail]
timeout = 1

:slightly_smiling_face:

ThomasTJdev commented 5 years ago

How does the firejail reset work?

  1. Is it nimwc or nimwc_main which is reset?
  2. I'm running NimWC with systemctl with an auto respawn param, will that cause any conflict?
  3. If I'm running multiple NimWC instances, and NimWC-demo uses noMnt, would the reset increase the risk for race conditions?
juancarlospaco commented 5 years ago
  1. nimwc_main
  2. No, I dont think so, It does not alter that.
  3. No, I dont think so, It does not alter that.

nimwc_main is stopped by Firejail, then nimwc starts it again, then cycle repeats.

Can be tested on Bash terminal like:

firejail --timeout=00:00:05 sleep 9

Will stop on 5 seconds instead of 9. :slightly_smiling_face:

ThomasTJdev commented 5 years ago

Testing in progress - 1 hour left ;) . When we integrate firejail more into NimWC, I think we should move the used config's to top and add comments. E.g.:

timeout=0               # Will kill program after n-hour
noX=true                # If you are running headless, set it to false
noMnt=true              # Deny access to e.g. /mnt
noDvd=true
noSound=true
noAutoPulse=true
no3d=true
noVideo=true

...
juancarlospaco commented 5 years ago

The config is "position agnostic", so yeah you can move them around freely, as long as they are under the same section, it just works. :+1:

ThomasTJdev commented 5 years ago

Ok if we comment and move timeout to top in config.