diff --git a/Dockerfile b/Dockerfile index e8965af..e6ca341 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,7 @@ WORKDIR /opt/code RUN rm -rf node_modules package_lock.json && \ npm install +# global deps +RUN npm i -g gulp-cli + CMD [ "/bin/sh", "-c", "/opt/code/run_instance.sh" ] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 822c058..1efb290 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,4 +8,6 @@ services: ports: - '${APP_PORT:-8080}:${APP_PORT:-8080}' volumes: - - './usercontent:/opt/code/usercontent' \ No newline at end of file + - './usercontent:/opt/code/usercontent' + # uncomment this for debug mode + #- './:/opt/code' \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..042a190 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,36 @@ +const gulp = require('gulp'); +const { spawn } = require('child_process'); +const log = require('fancy-log'); + +const spawn_dev = () => { + return spawn('node', ['--inspect=0.0.0.0', 'index.js'], {stdio: 'inherit'}); +} + +let node; +let shutdown = false; + +gulp.task('run_dev', (cb) => { + + log('Running application in development mode...'); + node = spawn_dev(); + + function watch(cb) { + if (shutdown == true) return cb(); + log('Files changed, restarting node...'); + node.kill('SIGTERM'); + node = spawn_dev(); + cb(); + } + + gulp.watch('.', { events: 'all' }, watch); + cb(); +}); + +function shutdown_f() { + shutdown = true; + node.kill('SIGINT'); + node.kill('SIGTERM'); +} + +process.on('SIGINT', shutdown_f); +process.on('SIGTERM', shutdown_f); \ No newline at end of file diff --git a/package.json b/package.json index 5588a67..45f4611 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,11 @@ "dotenv": "^16.0.3", "express": "^4.18.2", "express-async-handler": "^1.2.0", + "fancy-log": "^2.0.0", "glob": "^9.2.1", "pug": "^3.0.2" + }, + "devDependencies": { + "gulp": "^4.0.2" } } diff --git a/views/main.pug b/views/main.pug index 21f91e8..5669d1d 100644 --- a/views/main.pug +++ b/views/main.pug @@ -11,4 +11,5 @@ block content p(style='color:darkred;font-weight:bold;font-size:9pt') | Max uploads limit exceeded. No more uploads would be accepted. br - | Contact site administrator so they would increase the limit or delete some uploads. \ No newline at end of file + | Contact site administrator so they would increase the limit or delete some upload. + p= exceeded \ No newline at end of file