Closed gregorskii closed 5 years ago
@gregorskii can you link to the renderer rfc file in your PR comment ?
Updated
@gregorskii You can implement this pretty easily with a custom script and instantiating strapi with the right params.
gist:
scripts/dev.js
const strapiInstance = strapi({
autoReload: true
});
strapi.start()
package.json
{
//...
"scripts": {
"develop": "nodemon --ignore ... --watch ... scripts/dev.js"
}
}
@alexandrebodin I am using a similar shell script to https://github.com/strapi/strapi-docker/blob/master/strapi.sh, would I simply copy in the scripts/dev.js
gist into the container and replace strapi start &
with npm run develop &
?
@alexandrebodin I am using a similar shell script to https://github.com/strapi/strapi-docker/blob/master/strapi.sh, would I simply copy in the
scripts/dev.js
gist into the container and replacestrapi start &
withnpm run develop &
?
Yes you could do that
Yep this seems to work the final setup was:
ROOT/dev.js:
const strapi = require('strapi');
const strapiInstance = strapi({
autoReload: true
});
strapiInstance.start();
strapi.sh:
...
cd $APP_NAME
npm run develop &
strapiPID=$!
wait "$strapiPID"
package.json:
"develop": "nodemon -e js,json,html --ignore database/ dev.js",
I think that satisfies the requirements assuming its documented. Up to you guys if this RFC/GH issues is enough documentation.
@gregorskii Thank you for the example. I'm going to note this as a documentation request in our backlog and close. Feel free to discuss opening a PR with @lauriejim ;)
Note: the suggested docker-compose file from strapi-docker does not work as it recursively restarts strapi. The db file changes everytime strapi restarts which causes strapi to restart.
2021-07-07 20:22:49.383 UTC [2156] LOG: could not receive data from client: Connection reset by peer
strapi | [2021-07-07T20:22:49.965Z] warn License expired. Starting in CE
strapi | [2021-07-07T20:22:50.932Z] info File changed: /srv/app/db/pg_wal/000000010000000000000001
strapi | [2021-07-07T20:22:50.932Z] info The server is restarting
https://github.com/strapi/strapi-docker/blob/master/examples/postgresql/docker-compose.yml#L26
Workaround is to use
db:
container_name: postgres
image: postgres
environment:
- POSTGRES_PASSWORD=strapi
- POSTGRES_USER=strapi
- POSTGRES_DB=strapi
ports:
- 5432:5432
volumes:
- ./.tmp/postgres_db:/var/lib/postgresql/data
restart: always
See https://github.com/strapi/strapi/issues/4082
Link: https://github.com/gregorskii/rfcs/blob/rfc/file-reload/rfcs/0003-strapi-develop-file-reload.md