{"id":2222,"date":"2022-12-27T16:23:33","date_gmt":"2022-12-27T15:23:33","guid":{"rendered":"https:\/\/blog.kodono.info\/wordpress\/?p=2222"},"modified":"2024-03-14T15:44:04","modified_gmt":"2024-03-14T14:44:04","slug":"deploy-a-pcf-nodejs-app-as-a-scheduled-task","status":"publish","type":"post","link":"https:\/\/blog.kodono.info\/wordpress\/2022\/12\/27\/deploy-a-pcf-nodejs-app-as-a-scheduled-task\/","title":{"rendered":"Deploy a PCF NodeJS app as a scheduled task"},"content":{"rendered":"<p>I have a NodeJS app that runs as a process and that executes a task every 15 minutes using <code>node-schedule<\/code>.<\/p>\n<p>We first need a <b>manifest.yml<\/b> file that contains:<\/p>\n<pre>\r\n---\r\napplications:\r\n- name: APP-NAME\r\n  buildpack: nodejs_buildpack\r\n  no-route: true\r\n  health-check-type: process\r\n  env:\r\n    OPTIMIZE_MEMORY: true\r\n<\/pre>\n<p>The <code>no-route<\/code> parameter is <b>true<\/b> so that we don&#8217;t get a route assigned, and the\u00a0<code>health-check-type<\/code> is set to <b>process<\/b> so that the orchestrator monitors process availability and doesn&#8217;t try to ping a non-existent web endpoint. And <code>OPTIMIZE_MEMORY<\/code> in <a href=\"https:\/\/docs.cloudfoundry.org\/devguide\/deploy-apps\/manifest-attributes.html#env-block\">&#8220;env&#8221; section<\/a> is based on the <a href=\"https:\/\/docs.cloudfoundry.org\/buildpacks\/node\/node-tips.html\">Pivotal recommendations<\/a>.<\/p>\n<p>If you need to use a local package in your app, you&#8217;ll have to pack it up first. To do it, go to your local module folder, and type <code>npm pack<\/code>. It will create a <code>.tgz<\/code> file that you&#8217;ll have to store in a <b>local_modules<\/b> folder for your app. Next, use <code>npm install .\\local_modules\\package-1.2.3.tgz<\/code>.<\/p>\n<p>You can now deploy your app with <code>pcf push APP-NAME<\/code> and you can read the logs with <code>cf logs APP-NAME --recent<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a NodeJS app that runs as a process and that executes a task every 15 minutes using node-schedule. We first need a manifest.yml file that contains: &#8212; applications: &#8211; name: APP-NAME buildpack: nodejs_buildpack no-route: true health-check-type: process env: OPTIMIZE_MEMORY: true The no-route parameter is true so that we don&#8217;t get a route assigned, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","hide_page_title":"","footnotes":""},"categories":[7,23,170,20],"tags":[147,156,123,155],"class_list":["post-2222","post","type-post","status-publish","format-standard","hentry","category-application","category-debug","category-english","category-niveau-expert","tag-application","tag-debug","tag-english","tag-niveau-expert"],"_links":{"self":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/2222","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2222"}],"version-history":[{"count":4,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/2222\/revisions"}],"predecessor-version":[{"id":2287,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/2222\/revisions\/2287"}],"wp:attachment":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}