我永远用在node.js上运行我的Ghost博客平台。 据我所知,永远应该注意节点掉落并自动重启。 但是,如果我从应用程序下拉数据库,数据库再次可用时,不会像预期的那样恢复。 日志如下:
r31c.log:Error: Connection lost: The server closed the connection. r31c.log:error: Forever detected script exited with code: 8 r31c.log:error: Forever restarting script for 1 time r31c.log:ERROR: connect ECONNREFUSED, sql: create table `posts` (`id` int(11) unsigned not null not null auto_increment primary key, `uuid` varchar(36) not null, `title` varchar(150) not null, `slug` varchar(150) not null, `markdown` text, `html` text, `image` text, `featured` tinyint(1) not null default '0', `page` tinyint(1) not null default '0', `status` varchar(150) not null default 'draft', `language` varchar(6) not null default 'en_US', `meta_title` varchar(150), `meta_description` varchar(200), `author_id` int(11) not null, `created_at` datetime not null, `created_by` int(11) not null, `updated_at` datetime, `updated_by` int(11), `published_at` datetime, `published_by` int(11)) default character set utf8,alter table `posts` add unique posts_slug_unique(`slug`), bindings: r31c.log:error: Forever detected script was killed by signal: null r31c.log: throw arguments[1]; // Unhandled 'error' event r31c.log:Error: Cannot stop process that is not running.
在生产环境中,我强烈build议尝试使用Passenger Standalone,而不是永远使用,以增强实例的稳健性和可靠性:
如果你还想永久使用,你可以通过脚本来检查永久实例是否启动,如果启动则启动它。
尽pipe如此,检查与数据库的连接应该是一个可应用的事情。